Skip to content

Commit e445e08

Browse files
Ganesh Ramachandranadbridge
authored andcommitted
SERIAL_FC disabled, critical section API Updation
SERIAL_FC disabled, critical section API and Format changes updated
1 parent 19bb6cd commit e445e08

File tree

13 files changed

+49
-92
lines changed

13 files changed

+49
-92
lines changed

targets/TARGET_TOSHIBA/TARGET_TMPM066/PinNames.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extern "C" {
2626
#define PIN_POS(X) ((uint32_t)(X) & 0x7)
2727

2828
// Pin data, bit 31..16: Pin Function, bit 15..0: Pin Direction
29-
#define PIN_DATA(FUNC, DIR) (int)(((FUNC) << 16)| ((DIR) << 0))
29+
#define PIN_DATA(FUNC, DIR) (int)(((FUNC) << 16) | ((DIR) << 0))
3030
#define PIN_FUNC(X) (((X) & 0xffff0000) >> 16)
3131
#define PIN_DIR(X) ((X) & 0xffff)
3232

@@ -38,15 +38,15 @@ typedef enum {
3838

3939
typedef enum {
4040
// TMPM066 Pin Names
41-
PA0 = 0 << 3, PA1, PA2, PA3, PA4, PA5, PA6, PA7,
42-
PB0 = 1 << 3, PB1, PB2, PB3,
43-
PC0 = 2 << 3, PC1, PC2, PC3, PC4, PC5,
44-
PD0 = 3 << 3, PD1, PD2, PD3, PD4, PD5,
45-
PE0 = 4 << 3, PE1, PE2, PE3, PE4, PE5,
46-
PF0 = 5 << 3, PF1, PF2, PF3, PF4, PF5, PF6, PF7,
47-
PG0 = 6 << 3, PG1,
48-
PH0 = 7 << 3, PH1, PH2, PH3,
49-
PJ0 = 8 << 3, PJ1, PJ2, PJ3,
41+
PA0 = 0 << 3, PA1, PA2, PA3, PA4, PA5, PA6, PA7,
42+
PB0 = 1 << 3, PB1, PB2, PB3,
43+
PC0 = 2 << 3, PC1, PC2, PC3, PC4, PC5,
44+
PD0 = 3 << 3, PD1, PD2, PD3, PD4, PD5,
45+
PE0 = 4 << 3, PE1, PE2, PE3, PE4, PE5,
46+
PF0 = 5 << 3, PF1, PF2, PF3, PF4, PF5, PF6, PF7,
47+
PG0 = 6 << 3, PG1,
48+
PH0 = 7 << 3, PH1, PH2, PH3,
49+
PJ0 = 8 << 3, PJ1, PJ2, PJ3,
5050

5151
// Other mbed Pin Names
5252
LED1 = PB0,

targets/TARGET_TOSHIBA/TARGET_TMPM066/analogin_api.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
#define ADC_10BIT_RANGE 0x3FF
2222

2323
static const PinMap PinMap_ADC[] = {
24-
{PA0, ADC_A0, PIN_DATA(0, 0)},
25-
{PA1, ADC_A1, PIN_DATA(0, 0)},
26-
{PA2, ADC_A2, PIN_DATA(0, 0)},
27-
{PA3, ADC_A3, PIN_DATA(0, 0)},
28-
{PA4, ADC_A4, PIN_DATA(0, 0)},
29-
{PA5, ADC_A5, PIN_DATA(0, 0)},
30-
{PA6, ADC_A6, PIN_DATA(0, 0)},
31-
{PA7, ADC_A7, PIN_DATA(0, 0)},
32-
{NC, NC, 0}
24+
{PA0, ADC_A0, PIN_DATA(0, 0)},
25+
{PA1, ADC_A1, PIN_DATA(0, 0)},
26+
{PA2, ADC_A2, PIN_DATA(0, 0)},
27+
{PA3, ADC_A3, PIN_DATA(0, 0)},
28+
{PA4, ADC_A4, PIN_DATA(0, 0)},
29+
{PA5, ADC_A5, PIN_DATA(0, 0)},
30+
{PA6, ADC_A6, PIN_DATA(0, 0)},
31+
{PA7, ADC_A7, PIN_DATA(0, 0)},
32+
{NC, NC, 0}
3333
};
3434

3535
void analogin_init(analogin_t *obj, PinName pin)
@@ -72,7 +72,7 @@ uint16_t analogin_read_u16(analogin_t *obj)
7272
// Start ADC conversion
7373
ADC_Start();
7474
// Wait until AD conversion complete
75-
while(ADC_GetConvertState().Bit.NormalComplete != 1) {
75+
while (ADC_GetConvertState().Bit.NormalComplete != 1) {
7676
// Do nothing
7777
}
7878
// Convert result

targets/TARGET_TOSHIBA/TARGET_TMPM066/device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
#define DEVICE_ID_LENGTH 32
2020

2121
#include "objects.h"
22-
#include "stddef.h"
22+
#include <stddef.h>
2323

2424
#endif

targets/TARGET_TOSHIBA/TARGET_TMPM066/gpio_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void gpio_init(gpio_t *obj, PinName pin)
4242
obj->pin = pin;
4343
obj->mask = gpio_set(pin);
4444
obj->port = (GPIO_Port) (pin >> 3);
45-
if((PortName)obj->port == PortH) {
45+
if ((PortName)obj->port == PortH) {
4646
CG_SetFcPeriphA(CG_FC_PERIPH_PORTH, ENABLE);
4747
}
4848
if ((PortName)obj->port == PortJ) {
@@ -68,7 +68,7 @@ void gpio_dir(gpio_t *obj, PinDirection direction)
6868
// Set pin output
6969
GPIO_SetOutput(obj->port, obj->mask);
7070
break;
71-
case PIN_INOUT:
71+
case PIN_INOUT:
7272
// Set pin both input and output
7373
GPIO_SetOutputEnableReg(obj->port, obj->mask, ENABLE);
7474
GPIO_SetInputEnableReg(obj->port, obj->mask, ENABLE);
@@ -89,7 +89,7 @@ void gpio_write(gpio_t *obj, int value)
8989
}
9090
}
9191

92-
int gpio_read (gpio_t *obj)
92+
int gpio_read(gpio_t *obj)
9393
{
9494
// Read gpio object pin data
9595
return GPIO_ReadDataBit(obj->port, obj->mask);

targets/TARGET_TOSHIBA/TARGET_TMPM066/gpio_irq_api.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
#include "string.h"
1716
#include "gpio_irq_api.h"
1817
#include "mbed_error.h"
1918
#include "PeripheralNames.h"
2019
#include "pinmap.h"
20+
#include "mbed_critical.h"
2121

2222
#define CHANNEL_NUM 6
2323

@@ -103,19 +103,13 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
103103
{
104104
// Get gpio interrupt ID
105105
obj->irq_id = pinmap_peripheral(pin, PinMap_GPIO_IRQ);
106-
107-
// Disable interrupt by CPU
108-
__set_PRIMASK(1);
109-
106+
core_util_critical_section_enter();
110107
// Get pin mask
111108
obj->mask = (uint32_t)(1 << (pin & 0x07));
112-
113109
// Get GPIO port
114110
obj->port = (GPIO_Port)(pin >> 3);
115-
116111
// Set pin level as LOW
117112
GPIO_WriteDataBit(obj->port, obj->mask, 0);
118-
119113
// Enable gpio interrupt function
120114
pinmap_pinout(pin, PinMap_GPIO_IRQ);
121115

@@ -145,21 +139,15 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
145139

146140
// Save irq handler
147141
hal_irq_handler[obj->irq_src] = handler;
148-
149142
// Save irq id
150143
channel_ids[obj->irq_src] = id;
151-
152144
// Initialize interrupt event as both edges detection
153145
obj->event = INTIFAO_INT_ACTIVE_STATE_INVALID;
154-
155146
// Set interrupt event and enable INTx clear
156147
INTIFAO_SetSTBYReleaseINTSrc(obj->irq_src, (INTIFAO_INTActiveState)obj->event, ENABLE);
157-
158148
// Clear gpio pending interrupt
159149
NVIC_ClearPendingIRQ((IRQn_Type)obj->irq_id);
160-
161-
// Enable gpio interrupt
162-
__set_PRIMASK(0);
150+
core_util_critical_section_exit();;
163151

164152
return 0;
165153
}
@@ -218,7 +206,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
218206
}
219207
}
220208

221-
if (obj->event != INTIFAO_INT_ACTIVE_STATE_INVALID ) {
209+
if (obj->event != INTIFAO_INT_ACTIVE_STATE_INVALID) {
222210
// Set interrupt event and enable INTx clear
223211
INTIFAO_SetSTBYReleaseINTSrc(obj->irq_src, (INTIFAO_INTActiveState)obj->event, ENABLE);
224212
GPIO_SetOutputEnableReg(obj->port, obj->mask, DISABLE);

targets/TARGET_TOSHIBA/TARGET_TMPM066/gpio_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ typedef struct {
3030

3131
static inline int gpio_is_connected(const gpio_t *obj)
3232
{
33-
return obj->pin != (PinName)NC;
33+
return (obj->pin != (PinName)NC);
3434
}
3535

3636
#ifdef __cplusplus

targets/TARGET_TOSHIBA/TARGET_TMPM066/i2c_api.c

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
#include "PeripheralNames.h"
1919
#include "pinmap.h"
2020

21-
#define I2C_NACK (0)
22-
#define I2C_ACK (1)
23-
#define I2C_TIMEOUT (100000)
24-
#define SELF_ADDR (0xE0)
21+
#define I2C_NACK (0)
22+
#define I2C_ACK (1)
23+
#define I2C_NO_DATA (0)
24+
#define I2C_READ_ADDRESSED (1)
25+
#define I2C_WRITE_GENERAL (2)
26+
#define I2C_WRITE_ADDRESSED (3)
27+
#define SELF_ADDR (0xE0)
28+
#define I2C_TIMEOUT (100000)
2529

2630
static const PinMap PinMap_I2C_SDA[] = {
2731
{PC1, I2C_0, PIN_DATA(1, 2)},
@@ -42,7 +46,7 @@ typedef struct {
4246
uint32_t prsck;
4347
} I2C_clock_setting_t;
4448

45-
static const uint32_t I2C_SCK_DIVIDER_TBL[8] = { 20, 24, 32, 48, 80, 144, 272, 528}; // SCK Divider value table
49+
static const uint32_t I2C_SCK_DIVIDER_TBL[8] = {20, 24, 32, 48, 80, 144, 272, 528}; // SCK Divider value table
4650
static uint32_t start_flag = 0;
4751
I2C_clock_setting_t clk;
4852
I2C_State status;
@@ -68,7 +72,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl)
6872
I2CName i2c_name = (I2CName)pinmap_merge(i2c_sda, i2c_scl);
6973
MBED_ASSERT((int)i2c_name != NC);
7074

71-
switch(i2c_name) {
75+
switch (i2c_name) {
7276
case I2C_0:
7377
CG_SetFcPeriphA(CG_FC_PERIPH_I2C0, ENABLE);
7478
obj->i2c = TSB_I2C0;
@@ -153,7 +157,6 @@ int i2c_stop(i2c_t *obj)
153157
void i2c_reset(i2c_t *obj)
154158
{
155159
I2C_SWReset(obj->i2c);
156-
return;
157160
}
158161

159162
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)
165168
start_flag = 1; // Start Condition
166169
if (i2c_byte_write(obj, (int32_t)((uint32_t)address | 1U)) == I2C_ACK) {
167170
while (count < length) {
168-
int32_t pdata = i2c_byte_read(obj, ((count < (length - 1))? 0: 1));
171+
int32_t pdata = i2c_byte_read(obj, ((count < (length - 1)) ? 0 : 1));
169172
if (pdata < 0) {
170173
break;
171174
}
@@ -245,7 +248,7 @@ int i2c_byte_write(i2c_t *obj, int data)
245248

246249
I2C_ClearINTOutput(obj->i2c);
247250

248-
if(start_flag == 1) {
251+
if (start_flag == 1) {
249252
I2C_Start_Condition(obj, (uint32_t)data);
250253
start_flag = 0;
251254
} else {
@@ -265,14 +268,6 @@ int i2c_byte_write(i2c_t *obj, int data)
265268
return (result);
266269
}
267270

268-
269-
#if DEVICE_I2CSLAVE
270-
271-
#define I2C_NO_DATA (0)
272-
#define I2C_READ_ADDRESSED (1)
273-
#define I2C_WRITE_GENERAL (2)
274-
#define I2C_WRITE_ADDRESSED (3)
275-
276271
void i2c_slave_mode(i2c_t *obj, int enable_slave)
277272
{
278273
i2c_reset(obj);
@@ -293,7 +288,6 @@ void i2c_slave_mode(i2c_t *obj, int enable_slave)
293288
I2C_Init(obj->i2c, &obj->myi2c);
294289
}
295290

296-
297291
int i2c_slave_receive(i2c_t *obj)
298292
{
299293
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)
347341
obj->address = address & 0xFE;
348342
i2c_slave_mode(obj, 1);
349343
}
350-
351-
#endif
352-
353-
void INTI2C0_IRQHandler(void)
354-
{
355-
356-
}
357-
358-
void INTI2C1_IRQHandler(void)
359-
{
360-
361-
}

targets/TARGET_TOSHIBA/TARGET_TMPM066/pinmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void pin_function(PinName pin, int function)
3939
// Set function if function is in range
4040
if (func <= PIN_FUNC_MAX) {
4141
// Disable other functions
42-
for(i = 0; i < PIN_FUNC_MAX; i++) {
43-
if(i != (func - 1)) {
42+
for (i = 0; i < PIN_FUNC_MAX; i++) {
43+
if (i != (func - 1)) {
4444
GPIO_DisableFuncReg((GPIO_Port)port, i, (1 << bit));
4545
}
4646
}

targets/TARGET_TOSHIBA/TARGET_TMPM066/port_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void port_init(port_t *obj, PortName port, int mask, PinDirection dir)
3636
obj->port = port;
3737
obj->mask = mask;
3838

39-
if((PortName)obj->port == PortH) {
39+
if ((PortName)obj->port == PortH) {
4040
CG_SetFcPeriphA(CG_FC_PERIPH_PORTH, ENABLE);
4141
}
4242
if ((PortName)obj->port == PortJ) {

targets/TARGET_TOSHIBA/TARGET_TMPM066/serial_api.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "PeripheralNames.h"
1919
#include "pinmap.h"
2020

21-
#define UART_NUM 6
21+
#define UART_NUM 2
2222

2323
static const PinMap PinMap_UART_TX[] = {
2424
{PC2, SERIAL_0, PIN_DATA(1, 1)},
@@ -239,15 +239,3 @@ void serial_pinout_tx(PinName tx)
239239
{
240240
pinmap_pinout(tx, PinMap_UART_TX);
241241
}
242-
243-
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
244-
{
245-
}
246-
247-
void serial_break_set(serial_t *obj)
248-
{
249-
}
250-
251-
void serial_break_clear(serial_t *obj)
252-
{
253-
}

targets/TARGET_TOSHIBA/TARGET_TMPM066/sleep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include "sleep_api.h"
1717

1818
// number of warm-up cycle = warm-up time to set / input frequency cycle (s)
19-
// number of 3*10^-6 (s) / (1/12 (MHz) ) = 60000 = 0xea60
19+
// number of 3*10^-6 (s) / (1/12 (MHz)) = 60000 = 0xea60
2020
#define CG_WUODR_INT ((uint16_t)0xea60)
2121

2222
void external_losc_enable(void);

targets/TARGET_TOSHIBA/TARGET_TMPM066/us_ticker.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static uint8_t us_ticker_inited = 0; // Is ticker initialized yet?
2424
static volatile uint32_t acc_us_ticker = 0;
2525

2626
// 16Bb high timer counter
27-
static uint32_t us_ticker_16h = 0;
27+
static volatile uint32_t us_ticker_16h = 0;
2828

2929
void INT16A0_IRQHandler(void)
3030
{
@@ -57,11 +57,10 @@ void us_ticker_init(void)
5757
NVIC_EnableIRQ(INT16A0_IRQn);
5858
// Match counter set to max value
5959
TSB_T16A0->RG = TMR16A_100US;
60-
// TSB_T16A0->CP = 0x00;
6160
TSB_T16A0->RUN = TMR16A_RUN;
6261
}
6362

64-
uint32_t us_ticker_read()
63+
uint32_t us_ticker_read(void)
6564
{
6665
uint32_t ret_val = 0;
6766

targets/targets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3344,7 +3344,7 @@
33443344
"extra_labels": ["TOSHIBA"],
33453345
"macros": ["__TMPM066__", "CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\""],
33463346
"supported_toolchains": ["GCC_ARM", "ARM", "IAR"],
3347-
"device_has": ["ANALOGIN", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "SERIAL", "SERIAL_FC", "SLEEP", "I2C", "I2CSLAVE", "STDIO_MESSAGES", "PWMOUT"],
3347+
"device_has": ["ANALOGIN", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "SERIAL", "SLEEP", "I2C", "I2CSLAVE", "STDIO_MESSAGES", "PWMOUT"],
33483348
"device_name": "TMPM066FWUG",
33493349
"detect_code": ["7011"],
33503350
"release_versions": ["5"]

0 commit comments

Comments
 (0)