SERIAL_FC disabled, critical section API Updation

SERIAL_FC disabled, critical section API and Format changes updated
pull/4840/head
Ganesh Ramachandran 2017-08-04 17:28:38 +05:30 committed by Ganesh Ramachandran
parent bd8fa4eb70
commit 624620b0d2
13 changed files with 49 additions and 92 deletions

View File

@ -26,7 +26,7 @@ extern "C" {
#define PIN_POS(X) ((uint32_t)(X) & 0x7) #define PIN_POS(X) ((uint32_t)(X) & 0x7)
// Pin data, bit 31..16: Pin Function, bit 15..0: Pin Direction // Pin data, bit 31..16: Pin Function, bit 15..0: Pin Direction
#define PIN_DATA(FUNC, DIR) (int)(((FUNC) << 16)| ((DIR) << 0)) #define PIN_DATA(FUNC, DIR) (int)(((FUNC) << 16) | ((DIR) << 0))
#define PIN_FUNC(X) (((X) & 0xffff0000) >> 16) #define PIN_FUNC(X) (((X) & 0xffff0000) >> 16)
#define PIN_DIR(X) ((X) & 0xffff) #define PIN_DIR(X) ((X) & 0xffff)

View File

@ -72,7 +72,7 @@ uint16_t analogin_read_u16(analogin_t *obj)
// Start ADC conversion // Start ADC conversion
ADC_Start(); ADC_Start();
// Wait until AD conversion complete // Wait until AD conversion complete
while(ADC_GetConvertState().Bit.NormalComplete != 1) { while (ADC_GetConvertState().Bit.NormalComplete != 1) {
// Do nothing // Do nothing
} }
// Convert result // Convert result

View File

@ -19,6 +19,6 @@
#define DEVICE_ID_LENGTH 32 #define DEVICE_ID_LENGTH 32
#include "objects.h" #include "objects.h"
#include "stddef.h" #include <stddef.h>
#endif #endif

View File

@ -42,7 +42,7 @@ void gpio_init(gpio_t *obj, PinName pin)
obj->pin = pin; obj->pin = pin;
obj->mask = gpio_set(pin); obj->mask = gpio_set(pin);
obj->port = (GPIO_Port) (pin >> 3); obj->port = (GPIO_Port) (pin >> 3);
if((PortName)obj->port == PortH) { if ((PortName)obj->port == PortH) {
CG_SetFcPeriphA(CG_FC_PERIPH_PORTH, ENABLE); CG_SetFcPeriphA(CG_FC_PERIPH_PORTH, ENABLE);
} }
if ((PortName)obj->port == PortJ) { if ((PortName)obj->port == PortJ) {
@ -89,7 +89,7 @@ void gpio_write(gpio_t *obj, int value)
} }
} }
int gpio_read (gpio_t *obj) int gpio_read(gpio_t *obj)
{ {
// Read gpio object pin data // Read gpio object pin data
return GPIO_ReadDataBit(obj->port, obj->mask); return GPIO_ReadDataBit(obj->port, obj->mask);

View File

@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include "string.h"
#include "gpio_irq_api.h" #include "gpio_irq_api.h"
#include "mbed_error.h" #include "mbed_error.h"
#include "PeripheralNames.h" #include "PeripheralNames.h"
#include "pinmap.h" #include "pinmap.h"
#include "mbed_critical.h"
#define CHANNEL_NUM 6 #define CHANNEL_NUM 6
@ -103,19 +103,13 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
{ {
// Get gpio interrupt ID // Get gpio interrupt ID
obj->irq_id = pinmap_peripheral(pin, PinMap_GPIO_IRQ); obj->irq_id = pinmap_peripheral(pin, PinMap_GPIO_IRQ);
core_util_critical_section_enter();
// Disable interrupt by CPU
__set_PRIMASK(1);
// Get pin mask // Get pin mask
obj->mask = (uint32_t)(1 << (pin & 0x07)); obj->mask = (uint32_t)(1 << (pin & 0x07));
// Get GPIO port // Get GPIO port
obj->port = (GPIO_Port)(pin >> 3); obj->port = (GPIO_Port)(pin >> 3);
// Set pin level as LOW // Set pin level as LOW
GPIO_WriteDataBit(obj->port, obj->mask, 0); GPIO_WriteDataBit(obj->port, obj->mask, 0);
// Enable gpio interrupt function // Enable gpio interrupt function
pinmap_pinout(pin, PinMap_GPIO_IRQ); pinmap_pinout(pin, PinMap_GPIO_IRQ);
@ -145,21 +139,15 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
// Save irq handler // Save irq handler
hal_irq_handler[obj->irq_src] = handler; hal_irq_handler[obj->irq_src] = handler;
// Save irq id // Save irq id
channel_ids[obj->irq_src] = id; channel_ids[obj->irq_src] = id;
// Initialize interrupt event as both edges detection // Initialize interrupt event as both edges detection
obj->event = INTIFAO_INT_ACTIVE_STATE_INVALID; obj->event = INTIFAO_INT_ACTIVE_STATE_INVALID;
// Set interrupt event and enable INTx clear // Set interrupt event and enable INTx clear
INTIFAO_SetSTBYReleaseINTSrc(obj->irq_src, (INTIFAO_INTActiveState)obj->event, ENABLE); INTIFAO_SetSTBYReleaseINTSrc(obj->irq_src, (INTIFAO_INTActiveState)obj->event, ENABLE);
// Clear gpio pending interrupt // Clear gpio pending interrupt
NVIC_ClearPendingIRQ((IRQn_Type)obj->irq_id); NVIC_ClearPendingIRQ((IRQn_Type)obj->irq_id);
core_util_critical_section_exit();;
// Enable gpio interrupt
__set_PRIMASK(0);
return 0; return 0;
} }
@ -218,7 +206,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
} }
} }
if (obj->event != INTIFAO_INT_ACTIVE_STATE_INVALID ) { if (obj->event != INTIFAO_INT_ACTIVE_STATE_INVALID) {
// Set interrupt event and enable INTx clear // Set interrupt event and enable INTx clear
INTIFAO_SetSTBYReleaseINTSrc(obj->irq_src, (INTIFAO_INTActiveState)obj->event, ENABLE); INTIFAO_SetSTBYReleaseINTSrc(obj->irq_src, (INTIFAO_INTActiveState)obj->event, ENABLE);
GPIO_SetOutputEnableReg(obj->port, obj->mask, DISABLE); GPIO_SetOutputEnableReg(obj->port, obj->mask, DISABLE);

View File

@ -30,7 +30,7 @@ typedef struct {
static inline int gpio_is_connected(const gpio_t *obj) static inline int gpio_is_connected(const gpio_t *obj)
{ {
return obj->pin != (PinName)NC; return (obj->pin != (PinName)NC);
} }
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -20,8 +20,12 @@
#define I2C_NACK (0) #define I2C_NACK (0)
#define I2C_ACK (1) #define I2C_ACK (1)
#define I2C_TIMEOUT (100000) #define I2C_NO_DATA (0)
#define I2C_READ_ADDRESSED (1)
#define I2C_WRITE_GENERAL (2)
#define I2C_WRITE_ADDRESSED (3)
#define SELF_ADDR (0xE0) #define SELF_ADDR (0xE0)
#define I2C_TIMEOUT (100000)
static const PinMap PinMap_I2C_SDA[] = { static const PinMap PinMap_I2C_SDA[] = {
{PC1, I2C_0, PIN_DATA(1, 2)}, {PC1, I2C_0, PIN_DATA(1, 2)},
@ -42,7 +46,7 @@ typedef struct {
uint32_t prsck; uint32_t prsck;
} I2C_clock_setting_t; } I2C_clock_setting_t;
static const uint32_t I2C_SCK_DIVIDER_TBL[8] = { 20, 24, 32, 48, 80, 144, 272, 528}; // SCK Divider value table static const uint32_t I2C_SCK_DIVIDER_TBL[8] = {20, 24, 32, 48, 80, 144, 272, 528}; // SCK Divider value table
static uint32_t start_flag = 0; static uint32_t start_flag = 0;
I2C_clock_setting_t clk; I2C_clock_setting_t clk;
I2C_State status; I2C_State status;
@ -68,7 +72,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl)
I2CName i2c_name = (I2CName)pinmap_merge(i2c_sda, i2c_scl); I2CName i2c_name = (I2CName)pinmap_merge(i2c_sda, i2c_scl);
MBED_ASSERT((int)i2c_name != NC); MBED_ASSERT((int)i2c_name != NC);
switch(i2c_name) { switch (i2c_name) {
case I2C_0: case I2C_0:
CG_SetFcPeriphA(CG_FC_PERIPH_I2C0, ENABLE); CG_SetFcPeriphA(CG_FC_PERIPH_I2C0, ENABLE);
obj->i2c = TSB_I2C0; obj->i2c = TSB_I2C0;
@ -153,7 +157,6 @@ int i2c_stop(i2c_t *obj)
void i2c_reset(i2c_t *obj) void i2c_reset(i2c_t *obj)
{ {
I2C_SWReset(obj->i2c); I2C_SWReset(obj->i2c);
return;
} }
int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) int i2c_read(i2c_t *obj, int address, char *data, int length, int stop)
@ -165,7 +168,7 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop)
start_flag = 1; // Start Condition start_flag = 1; // Start Condition
if (i2c_byte_write(obj, (int32_t)((uint32_t)address | 1U)) == I2C_ACK) { if (i2c_byte_write(obj, (int32_t)((uint32_t)address | 1U)) == I2C_ACK) {
while (count < length) { while (count < length) {
int32_t pdata = i2c_byte_read(obj, ((count < (length - 1))? 0: 1)); int32_t pdata = i2c_byte_read(obj, ((count < (length - 1)) ? 0 : 1));
if (pdata < 0) { if (pdata < 0) {
break; break;
} }
@ -245,7 +248,7 @@ int i2c_byte_write(i2c_t *obj, int data)
I2C_ClearINTOutput(obj->i2c); I2C_ClearINTOutput(obj->i2c);
if(start_flag == 1) { if (start_flag == 1) {
I2C_Start_Condition(obj, (uint32_t)data); I2C_Start_Condition(obj, (uint32_t)data);
start_flag = 0; start_flag = 0;
} else { } else {
@ -265,14 +268,6 @@ int i2c_byte_write(i2c_t *obj, int data)
return (result); return (result);
} }
#if DEVICE_I2CSLAVE
#define I2C_NO_DATA (0)
#define I2C_READ_ADDRESSED (1)
#define I2C_WRITE_GENERAL (2)
#define I2C_WRITE_ADDRESSED (3)
void i2c_slave_mode(i2c_t *obj, int enable_slave) void i2c_slave_mode(i2c_t *obj, int enable_slave)
{ {
i2c_reset(obj); i2c_reset(obj);
@ -293,7 +288,6 @@ void i2c_slave_mode(i2c_t *obj, int enable_slave)
I2C_Init(obj->i2c, &obj->myi2c); I2C_Init(obj->i2c, &obj->myi2c);
} }
int i2c_slave_receive(i2c_t *obj) int i2c_slave_receive(i2c_t *obj)
{ {
int32_t result = I2C_NO_DATA; int32_t result = I2C_NO_DATA;
@ -347,15 +341,3 @@ void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask)
obj->address = address & 0xFE; obj->address = address & 0xFE;
i2c_slave_mode(obj, 1); i2c_slave_mode(obj, 1);
} }
#endif
void INTI2C0_IRQHandler(void)
{
}
void INTI2C1_IRQHandler(void)
{
}

View File

@ -39,8 +39,8 @@ void pin_function(PinName pin, int function)
// Set function if function is in range // Set function if function is in range
if (func <= PIN_FUNC_MAX) { if (func <= PIN_FUNC_MAX) {
// Disable other functions // Disable other functions
for(i = 0; i < PIN_FUNC_MAX; i++) { for (i = 0; i < PIN_FUNC_MAX; i++) {
if(i != (func - 1)) { if (i != (func - 1)) {
GPIO_DisableFuncReg((GPIO_Port)port, i, (1 << bit)); GPIO_DisableFuncReg((GPIO_Port)port, i, (1 << bit));
} }
} }

View File

@ -36,7 +36,7 @@ void port_init(port_t *obj, PortName port, int mask, PinDirection dir)
obj->port = port; obj->port = port;
obj->mask = mask; obj->mask = mask;
if((PortName)obj->port == PortH) { if ((PortName)obj->port == PortH) {
CG_SetFcPeriphA(CG_FC_PERIPH_PORTH, ENABLE); CG_SetFcPeriphA(CG_FC_PERIPH_PORTH, ENABLE);
} }
if ((PortName)obj->port == PortJ) { if ((PortName)obj->port == PortJ) {

View File

@ -18,7 +18,7 @@
#include "PeripheralNames.h" #include "PeripheralNames.h"
#include "pinmap.h" #include "pinmap.h"
#define UART_NUM 6 #define UART_NUM 2
static const PinMap PinMap_UART_TX[] = { static const PinMap PinMap_UART_TX[] = {
{PC2, SERIAL_0, PIN_DATA(1, 1)}, {PC2, SERIAL_0, PIN_DATA(1, 1)},
@ -239,15 +239,3 @@ void serial_pinout_tx(PinName tx)
{ {
pinmap_pinout(tx, PinMap_UART_TX); pinmap_pinout(tx, PinMap_UART_TX);
} }
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
{
}
void serial_break_set(serial_t *obj)
{
}
void serial_break_clear(serial_t *obj)
{
}

View File

@ -16,7 +16,7 @@
#include "sleep_api.h" #include "sleep_api.h"
// number of warm-up cycle = warm-up time to set / input frequency cycle (s) // number of warm-up cycle = warm-up time to set / input frequency cycle (s)
// number of 3*10^-6 (s) / (1/12 (MHz) ) = 60000 = 0xea60 // number of 3*10^-6 (s) / (1/12 (MHz)) = 60000 = 0xea60
#define CG_WUODR_INT ((uint16_t)0xea60) #define CG_WUODR_INT ((uint16_t)0xea60)
void external_losc_enable(void); void external_losc_enable(void);

View File

@ -24,7 +24,7 @@ static uint8_t us_ticker_inited = 0; // Is ticker initialized yet?
static volatile uint32_t acc_us_ticker = 0; static volatile uint32_t acc_us_ticker = 0;
// 16Bb high timer counter // 16Bb high timer counter
static uint32_t us_ticker_16h = 0; static volatile uint32_t us_ticker_16h = 0;
void INT16A0_IRQHandler(void) void INT16A0_IRQHandler(void)
{ {
@ -57,11 +57,10 @@ void us_ticker_init(void)
NVIC_EnableIRQ(INT16A0_IRQn); NVIC_EnableIRQ(INT16A0_IRQn);
// Match counter set to max value // Match counter set to max value
TSB_T16A0->RG = TMR16A_100US; TSB_T16A0->RG = TMR16A_100US;
// TSB_T16A0->CP = 0x00;
TSB_T16A0->RUN = TMR16A_RUN; TSB_T16A0->RUN = TMR16A_RUN;
} }
uint32_t us_ticker_read() uint32_t us_ticker_read(void)
{ {
uint32_t ret_val = 0; uint32_t ret_val = 0;

View File

@ -3356,7 +3356,7 @@
"extra_labels": ["TOSHIBA"], "extra_labels": ["TOSHIBA"],
"macros": ["__TMPM066__", "CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\""], "macros": ["__TMPM066__", "CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\""],
"supported_toolchains": ["GCC_ARM", "ARM", "IAR"], "supported_toolchains": ["GCC_ARM", "ARM", "IAR"],
"device_has": ["ANALOGIN", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "SERIAL", "SERIAL_FC", "SLEEP", "I2C", "I2CSLAVE", "STDIO_MESSAGES", "PWMOUT"], "device_has": ["ANALOGIN", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "SERIAL", "SLEEP", "I2C", "I2CSLAVE", "STDIO_MESSAGES", "PWMOUT"],
"device_name": "TMPM066FWUG", "device_name": "TMPM066FWUG",
"detect_code": ["7011"], "detect_code": ["7011"],
"release_versions": ["5"] "release_versions": ["5"]