The following steps show how to use two UART ports in CC2530 Z-Stack
1. Define HAL_UART=TRUE, HAL_UART_ISR=1, and HAL_UART_DMA=2 in compile options.
2. Initialize and use UART0 (P0_2 as RX/P0_3 as TX) as the followings:
void initUart0(halUARTCBack_t pf)
{
halUARTCfg_t uartConfig;
uartConfig.configured = TRUE;
uartConfig.baudRate = HAL_UART_BR_115200;
uartConfig.flowControl = FALSE;
uartConfig.flowControlThreshold = 48;
uartConfig.rx.maxBufSize = 128;
uartConfig.tx.maxBufSize = 128;
uartConfig.idleTimeout = 6;
uartConfig.intEnable = TRUE;
uartConfig.callBackFunc = pf;
HalUARTOpen (HAL_UART_PORT_0, &uartConfig);
}
void uart0RxCb( uint8 port, uint8 event )
{
uint8 ch;
while (Hal_UART_RxBufLen(port))
{
// Read one byte from UART to ch
HalUARTRead (port, &ch, 1);
}
}
initUart0(uart0RxCb);
//Output "UART0 output test" to P0.3
HalUARTWrite( HAL_UART_PORT_0, "UART0 output test", (byte)osal_strlen("UART0 output test"));
3. Initialize and use UART1 (P1_6 as TX/P1_7 as RX) as the followings:
void initUart1(halUARTCBack_t pf)
{
halUARTCfg_t uartConfig;
uartConfig.configured = TRUE;
uartConfig.baudRate = HAL_UART_BR_115200;
uartConfig.flowControl = FALSE;
uartConfig.flowControlThreshold = 48;
uartConfig.rx.maxBufSize = 128;
uartConfig.tx.maxBufSize = 128;
uartConfig.idleTimeout = 6;
uartConfig.intEnable = TRUE;
uartConfig.callBackFunc = pf;
HalUARTOpen (HAL_UART_PORT_1, &uartConfig);
}
void uart1RxCb( uint8 port, uint8 event )
{
uint8 ch;
while (Hal_UART_RxBufLen(port))
{
// Read one byte from UART to ch
HalUARTRead (port, &ch, 1);
}
}
initUart1(uart0RxCb);
//Output "UART1 output test" to P1.6
HalUARTWrite( HAL_UART_PORT_1, "UART1 output test", (byte)osal_strlen("UART1 output test"));
Thursday, September 8, 2016
Tuesday, September 6, 2016
How to porting collector example in TI-15.4 Stack from CC1310 LaunchPad to CC1310DK
You only have to revise the following red codes in CC1310_LAUNCHXL.h
to make it work. RLED on CC1310 LaunchPad is mapped to LED1 on CC1310DK, GLED on CC1310 LaunchPad is mapped to LED2 on CC1310DK, BTN-1 on CC1310 LaunchPad is mapped to LEFT BTN on CC1310DK, and BTN-2 on CC1310 LaunchPad is mapped to RIGHT BTN on CC1310DK.
/* Discrete outputs */
#define Board_RLED IOID_25
#define Board_GLED IOID_27
#define Board_LED_ON 1
#define Board_LED_OFF 0
/* Discrete inputs */
#define Board_BTN1 IOID_15
#define Board_BTN2 IOID_18
/* UART Board */
#define Board_UART_RX IOID_2 /* RXD */
#define Board_UART_TX IOID_3 /* TXD */
#define Board_UART_CTS IOID_19 /* CTS */
#define Board_UART_RTS IOID_14 /* RTS */
/* SPI Board */
#define Board_SPI0_MISO IOID_8 /* RF1.20 */
#define Board_SPI0_MOSI IOID_9 /* RF1.18 */
#define Board_SPI0_CLK IOID_10 /* RF1.16 */
#define Board_SPI0_CSN PIN_UNASSIGNED
#define Board_SPI1_MISO PIN_UNASSIGNED
#define Board_SPI1_MOSI PIN_UNASSIGNED
#define Board_SPI1_CLK PIN_UNASSIGNED
#define Board_SPI1_CSN PIN_UNASSIGNED
/* I2C */
#define Board_I2C0_SCL0 IOID_4
#define Board_I2C0_SDA0 IOID_5
/* SPI */
#define Board_SPI_FLASH_CS IOID_20
#define Board_FLASH_CS_ON 0
#define Board_FLASH_CS_OFF 1
/* Booster pack generic */
#define Board_DIO0 IOID_0
#define Board_DIO1_RFSW IOID_1
#define Board_DIO12 IOID_12
#define Board_DIO15 IOID_13
#define Board_DIO16_TDO IOID_16
#define Board_DIO17_TDI IOID_17
#define Board_DIO21 IOID_21
#define Board_DIO22 IOID_22
#define Board_DIO23_ANALOG IOID_23
#define Board_DIO24_ANALOG IOID_24
#define Board_DIO25_ANALOG IOID_26
#define Board_DIO26_ANALOG IOID_26
#define Board_DIO27_ANALOG IOID_26
#define Board_DIO28_ANALOG IOID_28
#define Board_DIO29_ANALOG IOID_29
#define Board_DIO30_ANALOG IOID_30
/* Discrete outputs */
#define Board_RLED IOID_25
#define Board_GLED IOID_27
#define Board_LED_ON 1
#define Board_LED_OFF 0
/* Discrete inputs */
#define Board_BTN1 IOID_15
#define Board_BTN2 IOID_18
/* UART Board */
#define Board_UART_RX IOID_2 /* RXD */
#define Board_UART_TX IOID_3 /* TXD */
#define Board_UART_CTS IOID_19 /* CTS */
#define Board_UART_RTS IOID_14 /* RTS */
/* SPI Board */
#define Board_SPI0_MISO IOID_8 /* RF1.20 */
#define Board_SPI0_MOSI IOID_9 /* RF1.18 */
#define Board_SPI0_CLK IOID_10 /* RF1.16 */
#define Board_SPI0_CSN PIN_UNASSIGNED
#define Board_SPI1_MISO PIN_UNASSIGNED
#define Board_SPI1_MOSI PIN_UNASSIGNED
#define Board_SPI1_CLK PIN_UNASSIGNED
#define Board_SPI1_CSN PIN_UNASSIGNED
/* I2C */
#define Board_I2C0_SCL0 IOID_4
#define Board_I2C0_SDA0 IOID_5
/* SPI */
#define Board_SPI_FLASH_CS IOID_20
#define Board_FLASH_CS_ON 0
#define Board_FLASH_CS_OFF 1
/* Booster pack generic */
#define Board_DIO0 IOID_0
#define Board_DIO1_RFSW IOID_1
#define Board_DIO12 IOID_12
#define Board_DIO15 IOID_13
#define Board_DIO16_TDO IOID_16
#define Board_DIO17_TDI IOID_17
#define Board_DIO21 IOID_21
#define Board_DIO22 IOID_22
#define Board_DIO23_ANALOG IOID_23
#define Board_DIO24_ANALOG IOID_24
#define Board_DIO25_ANALOG IOID_26
#define Board_DIO26_ANALOG IOID_26
#define Board_DIO27_ANALOG IOID_26
#define Board_DIO28_ANALOG IOID_28
#define Board_DIO29_ANALOG IOID_29
#define Board_DIO30_ANALOG IOID_30
Subscribe to:
Posts (Atom)