Skip to content

Commit cc29812

Browse files
Ganesh Ramachandranadbridge
authored andcommitted
Dynamic vector relocation and formatting changes
1 parent fb98c9b commit cc29812

File tree

6 files changed

+24
-39
lines changed

6 files changed

+24
-39
lines changed

targets/TARGET_TOSHIBA/TARGET_TMPM46B/Periph_Driver/inc/tx04_common.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
typedef enum {
1919
SUCCESS = 0U,
20-
ERROR = 1U
20+
ERROR = 1U,
21+
FAIL = -1
2122
} Result;
2223

2324
typedef enum {

targets/TARGET_TOSHIBA/TARGET_TMPM46B/flash_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int32_t flash_free(flash_t *obj)
8484
#endif
8585
int32_t flash_erase_sector(flash_t *obj, uint32_t address)
8686
{
87-
int status = ERROR;
87+
int status = FAIL;
8888
/* We need to prevent flash accesses during erase operation */
8989
core_util_critical_section_enter();
9090

@@ -110,7 +110,7 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
110110
if (FC_SUCCESS == FC_WritePage((uint32_t)address, (uint32_t *)data)) { /* write one page every time */
111111
/* Do nothing */
112112
} else {
113-
status = ERROR;
113+
status = FAIL;
114114
break;
115115
}
116116
size = size - PROGRAM_WIRTE_MAX;
@@ -120,7 +120,7 @@ int32_t flash_program_page(flash_t *obj, uint32_t address, const uint8_t *data,
120120
if (FC_SUCCESS == FC_WritePage((uint32_t)address, (uint32_t *)data)) { /* write the last data, no more than one page */
121121
/* Do nothing */
122122
} else {
123-
status = ERROR;
123+
status = FAIL;
124124
}
125125

126126
core_util_critical_section_exit();

targets/TARGET_TOSHIBA/TARGET_TMPM46B/pwmout_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void pwmout_write(pwmout_t *obj, float value)
108108
}
109109
TMRB_SetFlipFlop(obj->channel, &FFStruct);
110110

111-
if (obj->period > 0.7){
111+
if (obj->period > 0.7) {
112112
value = 1; //TMPM46B duty cycle should be < 700ms, above 700ms fixed 50% duty cycle
113113
}
114114
// Store the new leading_timing value
@@ -148,7 +148,7 @@ void pwmout_period_us(pwmout_t *obj, int us)
148148
seconds = (float)((us) / 1000000.0f);
149149
obj->period = seconds;
150150

151-
if (obj->period > 0.7){
151+
if (obj->period > 0.7) {
152152
clk_freq = (CLOCK_FREQUENCY / 2);
153153
} else {
154154
clk_freq = CLOCK_FREQUENCY;

targets/TARGET_TOSHIBA/TARGET_TMPM46B/spi_api.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,6 @@ static const PinMap PinMap_SPI_SSEL[] = {
6060
{NC, NC, 0}
6161
};
6262

63-
typedef enum {
64-
SPI_SPH0_SPO0 = 0, // [Clock Phase 0, Clock Polarity 0] = 0
65-
SPI_SPH0_SPO1, // [Clock Phase 0, Clock Polarity 1] = 1
66-
SPI_SPH1_SPO0, // [Clock Phase 1, Clock Polarity 0] = 2
67-
SPI_SPH1_SPO1 // [Clock Phase 1, Clock Polarity 1] = 3
68-
} SPI_MODE;
69-
70-
typedef enum {
71-
SPI_MASTER,
72-
SPI_SLAVE
73-
} spi_mode;
74-
7563
#define TMPM46B_SPI_2_FMAX 20000000
7664
#define TMPM46B_SPI_FMAX 10000000
7765

@@ -149,7 +137,7 @@ void spi_free(spi_t *obj)
149137
void spi_format(spi_t *obj, int bits, int mode, int slave)
150138
{
151139
TSB_SSP_TypeDef* spi;
152-
MBED_ASSERT(slave == SPI_MASTER); // Master mode only
140+
MBED_ASSERT(slave == SSP_MASTER); // Master mode only
153141

154142
spi = obj->spi;
155143

@@ -194,9 +182,9 @@ void spi_frequency(spi_t *obj, int hz)
194182

195183
spi = obj->spi;
196184
fr_gear = SystemCoreClock / hz;
197-
if (fr_gear < 48){
185+
if (fr_gear < 48) {
198186
cur_cpsdvsr = fr_gear;
199-
}
187+
}
200188
while (best_diff != 0 && cur_cpsdvsr <= 254) {
201189
cur_scr = fr_gear / cur_cpsdvsr - 1;
202190

targets/TARGET_TOSHIBA/TARGET_TMPM46B/trng_api.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,18 @@ int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_l
6565

6666
*output_length = 0;
6767

68-
if (!obj->trng_init){
68+
if (!obj->trng_init) {
6969
error("TRNG is not Initialised");
70-
return -1;
70+
return FAIL; // fail i.e. -1
7171
}
7272

73-
while (ESG_GetIntStatus() == DISABLE)
74-
{
75-
// Wait for ESG core for generating an interrupt
73+
while (ESG_GetIntStatus() == DISABLE) {
74+
// Wait for ESG core for generating an interrupt
7675
}
7776
// Interrupt clearing
7877
ret = ESG_ClrInt();
79-
if (ret == ERROR)
80-
{
81-
return ret;
78+
if (ret == ERROR) {
79+
return FAIL; // fail i.e. -1
8280
}
8381
// Get the calculation result
8482
ESG_GetResult((uint32_t*)random); //512-bit entropy
@@ -90,8 +88,11 @@ int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_l
9088
}
9189
*output_length = i;
9290
//clear and restart the ESG core
93-
ESG_IPReset();
91+
ESG_IPReset();
9492
ret |= ESG_Startup();
93+
if (ret == ERROR) {
94+
return FAIL; // fail i.e. -1
95+
}
9596

9697
return ret;
9798
}

targets/TARGET_TOSHIBA/TARGET_TMPM46B/us_ticker.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,11 @@
2222
static uint8_t us_ticker_inited = 0; // Is ticker initialized yet?
2323
static volatile uint32_t us_ticker = 0; // timer counter
2424

25-
void INTTB1_IRQHandler(void)
26-
{
27-
// This function is going to disable the interrupts if there are
28-
us_ticker_irq_handler();
29-
}
30-
3125
const ticker_info_t* us_ticker_get_info()
3226
{
3327
static const ticker_info_t info = {
34-
1875000,//1875000,
35-
16 // 16 bit counter
28+
1875000, // 1875000,
29+
16 // 16 bit counter
3630
};
3731
return &info;
3832
}
@@ -91,7 +85,7 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
9185

9286
const uint32_t now_ticks = us_ticker_read();
9387
uint32_t delta_ticks =
94-
timestamp >= now_ticks ? timestamp - now_ticks : (uint32_t)((uint64_t) timestamp + 0xFFFF - now_ticks);
88+
timestamp >= now_ticks ? timestamp - now_ticks : (uint32_t)((uint64_t) timestamp + 0xFFFF - now_ticks);
9589

9690
if (delta_ticks == 0) {
9791
/* The requested delay is less than the minimum resolution of this counter. */
@@ -101,6 +95,7 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
10195
// Ticker interrupt handle
10296
TMRB_Enable(TSB_TB1);
10397
TMRB_SetRunState(TSB_TB1, TMRB_STOP);
98+
NVIC_SetVector(INTTB1_IRQn, (uint32_t)us_ticker_irq_handler);
10499
NVIC_EnableIRQ(INTTB1_IRQn);
105100

106101
// Split delta for preventing the Multiply overflowing

0 commit comments

Comments
 (0)