Skip to content

Commit 4e85fbf

Browse files
author
Jenny Plunkett
authored
Merge pull request ARMmbed#28 from yennster/uart-debug
Re-added UART clock enable
2 parents ac017e8 + 9f5dae0 commit 4e85fbf

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed

targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/PeripheralNames.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ typedef enum {
5454
#define STDIO_UART_RX USBRX
5555
#define STDIO_UART UART_0
5656

57-
#define MBED_UART0 USBTX, USBRX
57+
#define MBED_UART0 P55, P57
58+
#define MBED_UART1 P07, P08
5859
#define MBED_UARTUSB USBTX, USBRX
5960

6061
#ifdef __cplusplus

targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/device/CC3220SF.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,13 @@ typedef struct
172172
__IO uint32_t MIS; /*!< Masked Interrupt Status , Address offset : 0x40 */
173173
__O uint32_t ICR; /*!< Interrupt Clear, Address offset : 0x44 */
174174
__IO uint32_t DMACTL; /*!< DMA Control, Address offset : 0x48 */
175-
//uint32_t RESERVED1[6];
176-
//__IO uint32_t LCTL; /*!< Address offset : 0x90 */
177-
//__IO uint32_t LSS; /*!< Address offset : 0x94 */
178-
//__IO uint32_t LTIM; /*!< Address offset : 0x98 */
179-
//__IO uint32_t 9BITADDR; /*!< Address offset : 0xA4 */
180-
//__IO uint32_t 9BITMASK; /*!< Address offset : 0xA8 */
181-
//__IO uint32_t PP; /*!< Address offset : 0xFC0 */
182-
//__IO uint32_t CC; /*!< Address offset : 0xFC8 */
175+
__IO uint32_t LCTL; /*!< Address offset : 0x90 */
176+
__IO uint32_t LSS; /*!< Address offset : 0x94 */
177+
__IO uint32_t LTIM; /*!< Address offset : 0x98 */
178+
__IO uint32_t BITADDR; /*!< 9BITADDR Address offset : 0xA4 */
179+
__IO uint32_t BITMASK; /*!< 9BITMASK Address offset : 0xA8 */
180+
__IO uint32_t PP; /*!< Address offset : 0xFC0 */
181+
__IO uint32_t CC; /*!< Address offset : 0xFC8 */
183182
} CC3220SF_UART_TypeDef;
184183

185184

targets/TARGET_TI/TARGET_CC32XX/TARGET_CC3220SF/serial_api.c

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,18 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
149149
obj->index = 0;
150150
obj->baseAddr = CC3220SF_UARTA0_BASE;
151151
obj->powerMgrId = 12; /*!< Resource ID: UART 0 */
152-
obj->intNum = INT_UARTA0;
152+
obj->intNum = INT_UARTA0_IRQn;
153153
obj->peripheralId = PRCM_UARTA0;
154+
MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
154155
}
155156
break;
156157
case UART_1: {
157158
obj->index = 1;
158159
obj->baseAddr = CC3220SF_UARTA1_BASE;
159160
obj->powerMgrId = 13; /*!< Resource ID: UART 1 */
160-
obj->intNum = INT_UARTA1;
161+
obj->intNum = INT_UARTA1_IRQn;
161162
obj->peripheralId = PRCM_UARTA1;
163+
MAP_PRCMPeripheralClkEnable(PRCM_UARTA1, PRCM_RUN_MODE_CLK);
162164
}
163165
break;
164166
}
@@ -247,6 +249,24 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
247249
/******************************************************************************
248250
* INTERRUPTS HANDLING
249251
******************************************************************************/
252+
static inline void uart_irq(uint32_t iir, uint32_t index, CC3220SF_UART_TypeDef *puart) {
253+
SerialIrq irq_type;
254+
switch(iir) {
255+
case 1: irq_type = TxIrq; break;
256+
case 2: irq_type = RxIrq; break;
257+
default: return;
258+
}
259+
}
260+
261+
void uart0_irq() {
262+
int status = MAP_UARTIntStatus(CC3220SF_UARTA0_BASE, false);
263+
uart_irq(status, 0, (CC3220SF_UART_TypeDef *)CC3220SF_UART0);
264+
}
265+
void uart1_irq() {
266+
int status = MAP_UARTIntStatus(CC3220SF_UARTA1_BASE, false);
267+
uart_irq(status, 1, (CC3220SF_UART_TypeDef *)CC3220SF_UART1);
268+
}
269+
250270
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id) {
251271
irq_handler = handler;
252272
uart_data[obj->index].serial_irq_id = id;
@@ -255,14 +275,10 @@ void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id) {
255275
static void serial_irq_set_internal(serial_t *obj, SerialIrq irq, uint32_t enable) {
256276
// TODO
257277
IRQn_Type irq_n = (IRQn_Type)0;
258-
//uint32_t vector = 0;
278+
uint32_t vector = 0;
259279
switch ((int)obj->uart) {
260-
case UART_0:
261-
irq_n = INT_UARTA0_IRQn;
262-
break;
263-
case UART_1:
264-
irq_n = INT_UARTA1_IRQn;
265-
break;
280+
case UART_0: irq_n = INT_UARTA0_IRQn; vector = (uint32_t)&uart0_irq; break;
281+
case UART_1: irq_n = INT_UARTA1_IRQn; vector = (uint32_t)&uart1_irq; break;
266282
}
267283
}
268284

@@ -322,6 +338,7 @@ void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, Pi
322338
// Check type(s) of flow control to use
323339
UARTName uart_rts = (UARTName)pinmap_find_peripheral(rxflow, PinMap_UART_RTS);
324340
UARTName uart_cts = (UARTName)pinmap_find_peripheral(txflow, PinMap_UART_CTS);
341+
if(type != FlowControlNone) MBED_ASSERT((int)uart_rts != NC || (int)uart_cts != NC);
325342

326343
switch(type) {
327344
case FlowControlRTS:

0 commit comments

Comments
 (0)