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)
// 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_DIR(X) ((X) & 0xffff)
@ -38,15 +38,15 @@ typedef enum {
typedef enum {
// TMPM066 Pin Names
PA0 = 0 << 3, PA1, PA2, PA3, PA4, PA5, PA6, PA7,
PB0 = 1 << 3, PB1, PB2, PB3,
PC0 = 2 << 3, PC1, PC2, PC3, PC4, PC5,
PD0 = 3 << 3, PD1, PD2, PD3, PD4, PD5,
PE0 = 4 << 3, PE1, PE2, PE3, PE4, PE5,
PF0 = 5 << 3, PF1, PF2, PF3, PF4, PF5, PF6, PF7,
PG0 = 6 << 3, PG1,
PH0 = 7 << 3, PH1, PH2, PH3,
PJ0 = 8 << 3, PJ1, PJ2, PJ3,
PA0 = 0 << 3, PA1, PA2, PA3, PA4, PA5, PA6, PA7,
PB0 = 1 << 3, PB1, PB2, PB3,
PC0 = 2 << 3, PC1, PC2, PC3, PC4, PC5,
PD0 = 3 << 3, PD1, PD2, PD3, PD4, PD5,
PE0 = 4 << 3, PE1, PE2, PE3, PE4, PE5,
PF0 = 5 << 3, PF1, PF2, PF3, PF4, PF5, PF6, PF7,
PG0 = 6 << 3, PG1,
PH0 = 7 << 3, PH1, PH2, PH3,
PJ0 = 8 << 3, PJ1, PJ2, PJ3,
// Other mbed Pin Names
LED1 = PB0,

View File

@ -21,15 +21,15 @@
#define ADC_10BIT_RANGE 0x3FF
static const PinMap PinMap_ADC[] = {
{PA0, ADC_A0, PIN_DATA(0, 0)},
{PA1, ADC_A1, PIN_DATA(0, 0)},
{PA2, ADC_A2, PIN_DATA(0, 0)},
{PA3, ADC_A3, PIN_DATA(0, 0)},
{PA4, ADC_A4, PIN_DATA(0, 0)},
{PA5, ADC_A5, PIN_DATA(0, 0)},
{PA6, ADC_A6, PIN_DATA(0, 0)},
{PA7, ADC_A7, PIN_DATA(0, 0)},
{NC, NC, 0}
{PA0, ADC_A0, PIN_DATA(0, 0)},
{PA1, ADC_A1, PIN_DATA(0, 0)},
{PA2, ADC_A2, PIN_DATA(0, 0)},
{PA3, ADC_A3, PIN_DATA(0, 0)},
{PA4, ADC_A4, PIN_DATA(0, 0)},
{PA5, ADC_A5, PIN_DATA(0, 0)},
{PA6, ADC_A6, PIN_DATA(0, 0)},
{PA7, ADC_A7, PIN_DATA(0, 0)},
{NC, NC, 0}
};
void analogin_init(analogin_t *obj, PinName pin)
@ -72,7 +72,7 @@ uint16_t analogin_read_u16(analogin_t *obj)
// Start ADC conversion
ADC_Start();
// Wait until AD conversion complete
while(ADC_GetConvertState().Bit.NormalComplete != 1) {
while (ADC_GetConvertState().Bit.NormalComplete != 1) {
// Do nothing
}
// Convert result

View File

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

View File

@ -42,7 +42,7 @@ void gpio_init(gpio_t *obj, PinName pin)
obj->pin = pin;
obj->mask = gpio_set(pin);
obj->port = (GPIO_Port) (pin >> 3);
if((PortName)obj->port == PortH) {
if ((PortName)obj->port == PortH) {
CG_SetFcPeriphA(CG_FC_PERIPH_PORTH, ENABLE);
}
if ((PortName)obj->port == PortJ) {
@ -68,7 +68,7 @@ void gpio_dir(gpio_t *obj, PinDirection direction)
// Set pin output
GPIO_SetOutput(obj->port, obj->mask);
break;
case PIN_INOUT:
case PIN_INOUT:
// Set pin both input and output
GPIO_SetOutputEnableReg(obj->port, obj->mask, ENABLE);
GPIO_SetInputEnableReg(obj->port, obj->mask, ENABLE);
@ -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
return GPIO_ReadDataBit(obj->port, obj->mask);

View File

@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "string.h"
#include "gpio_irq_api.h"
#include "mbed_error.h"
#include "PeripheralNames.h"
#include "pinmap.h"
#include "mbed_critical.h"
#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
obj->irq_id = pinmap_peripheral(pin, PinMap_GPIO_IRQ);
// Disable interrupt by CPU
__set_PRIMASK(1);
core_util_critical_section_enter();
// Get pin mask
obj->mask = (uint32_t)(1 << (pin & 0x07));
// Get GPIO port
obj->port = (GPIO_Port)(pin >> 3);
// Set pin level as LOW
GPIO_WriteDataBit(obj->port, obj->mask, 0);
// Enable gpio interrupt function
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
hal_irq_handler[obj->irq_src] = handler;
// Save irq id
channel_ids[obj->irq_src] = id;
// Initialize interrupt event as both edges detection
obj->event = INTIFAO_INT_ACTIVE_STATE_INVALID;
// Set interrupt event and enable INTx clear
INTIFAO_SetSTBYReleaseINTSrc(obj->irq_src, (INTIFAO_INTActiveState)obj->event, ENABLE);
// Clear gpio pending interrupt
NVIC_ClearPendingIRQ((IRQn_Type)obj->irq_id);
// Enable gpio interrupt
__set_PRIMASK(0);
core_util_critical_section_exit();;
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
INTIFAO_SetSTBYReleaseINTSrc(obj->irq_src, (INTIFAO_INTActiveState)obj->event, ENABLE);
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)
{
return obj->pin != (PinName)NC;
return (obj->pin != (PinName)NC);
}
#ifdef __cplusplus

View File

@ -18,10 +18,14 @@
#include "PeripheralNames.h"
#include "pinmap.h"
#define I2C_NACK (0)
#define I2C_ACK (1)
#define I2C_TIMEOUT (100000)
#define SELF_ADDR (0xE0)
#define I2C_NACK (0)
#define I2C_ACK (1)
#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 I2C_TIMEOUT (100000)
static const PinMap PinMap_I2C_SDA[] = {
{PC1, I2C_0, PIN_DATA(1, 2)},
@ -42,7 +46,7 @@ typedef struct {
uint32_t prsck;
} 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;
I2C_clock_setting_t clk;
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);
MBED_ASSERT((int)i2c_name != NC);
switch(i2c_name) {
switch (i2c_name) {
case I2C_0:
CG_SetFcPeriphA(CG_FC_PERIPH_I2C0, ENABLE);
obj->i2c = TSB_I2C0;
@ -153,7 +157,6 @@ int i2c_stop(i2c_t *obj)
void i2c_reset(i2c_t *obj)
{
I2C_SWReset(obj->i2c);
return;
}
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
if (i2c_byte_write(obj, (int32_t)((uint32_t)address | 1U)) == I2C_ACK) {
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) {
break;
}
@ -245,7 +248,7 @@ int i2c_byte_write(i2c_t *obj, int data)
I2C_ClearINTOutput(obj->i2c);
if(start_flag == 1) {
if (start_flag == 1) {
I2C_Start_Condition(obj, (uint32_t)data);
start_flag = 0;
} else {
@ -265,14 +268,6 @@ int i2c_byte_write(i2c_t *obj, int data)
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)
{
i2c_reset(obj);
@ -293,7 +288,6 @@ void i2c_slave_mode(i2c_t *obj, int enable_slave)
I2C_Init(obj->i2c, &obj->myi2c);
}
int i2c_slave_receive(i2c_t *obj)
{
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;
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
if (func <= PIN_FUNC_MAX) {
// Disable other functions
for(i = 0; i < PIN_FUNC_MAX; i++) {
if(i != (func - 1)) {
for (i = 0; i < PIN_FUNC_MAX; i++) {
if (i != (func - 1)) {
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->mask = mask;
if((PortName)obj->port == PortH) {
if ((PortName)obj->port == PortH) {
CG_SetFcPeriphA(CG_FC_PERIPH_PORTH, ENABLE);
}
if ((PortName)obj->port == PortJ) {

View File

@ -18,7 +18,7 @@
#include "PeripheralNames.h"
#include "pinmap.h"
#define UART_NUM 6
#define UART_NUM 2
static const PinMap PinMap_UART_TX[] = {
{PC2, SERIAL_0, PIN_DATA(1, 1)},
@ -239,15 +239,3 @@ void serial_pinout_tx(PinName 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"
// 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)
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;
// 16Bb high timer counter
static uint32_t us_ticker_16h = 0;
static volatile uint32_t us_ticker_16h = 0;
void INT16A0_IRQHandler(void)
{
@ -57,11 +57,10 @@ void us_ticker_init(void)
NVIC_EnableIRQ(INT16A0_IRQn);
// Match counter set to max value
TSB_T16A0->RG = TMR16A_100US;
// TSB_T16A0->CP = 0x00;
TSB_T16A0->RUN = TMR16A_RUN;
}
uint32_t us_ticker_read()
uint32_t us_ticker_read(void)
{
uint32_t ret_val = 0;

View File

@ -3356,7 +3356,7 @@
"extra_labels": ["TOSHIBA"],
"macros": ["__TMPM066__", "CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\""],
"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",
"detect_code": ["7011"],
"release_versions": ["5"]