configs/launchxl-cc1312r1: Add support for on-board LEDs and buttons.
This commit is contained in:
parent
9a11f821ee
commit
9e1cb2491c
@ -158,6 +158,7 @@
|
||||
*/
|
||||
|
||||
#define BUTTON_SW8 0
|
||||
#define NUM_BUTTONS 1
|
||||
|
||||
#define BUTTON_SW8_BIT (1 << BUTTON_SW8)
|
||||
|
||||
|
@ -27,6 +27,10 @@ Serial Console
|
||||
The on-board XDS110 Debugger provide a USB virtual serial console using
|
||||
UART0 (PA0/U0RX and PA1/U0TX).
|
||||
|
||||
A J-Link debugger is used (see below), then the RXD/TXD jumper pins can
|
||||
be used to support a serial console through appropriate TTL level adapater
|
||||
(RS-232 or USB serial).
|
||||
|
||||
LEDs and Buttons
|
||||
================
|
||||
|
||||
@ -39,17 +43,23 @@ Buttons
|
||||
Using J-Link
|
||||
============
|
||||
|
||||
Reference https://wiki.segger.com/CC1310_LaunchPad (for CC1310)
|
||||
Reference https://wiki.segger.com/CC1310_LaunchPad:
|
||||
|
||||
When shipped, the TI CC1310 LaunchPad evaluation board is configured to be
|
||||
used with the on-board debug probe. In order to use it with J-Link, the
|
||||
on-board debug probe needs to be isolated to make sure that it does not
|
||||
drive the debug signals. This can be done by removing some jumpers next
|
||||
to the XDS110 Out / CC1310 In connector [RXD, TXD, RST, TMS, TCK, TDO, TDI,
|
||||
WDO]. After isolating the on-board probe, the CC130F128 device can be
|
||||
debugged using J-Link. Please note, that the J-Link needs to be connected
|
||||
to the board using the CC1310 using the micro JTAG connector marked "In".
|
||||
SWO]. After isolating the on-board probe, the CC130F128 device can be
|
||||
debugged using J-Link. The J-Link needs to be connected to the board
|
||||
using the micro JTAG connector marked "In".
|
||||
|
||||
The RXD/TXD can then be used for a Serial console using the appropriate
|
||||
TTL adapter (TTL to RS-232 or TTL to USB serial).
|
||||
I use the Olimex ARM-JTAG-20-10 to interface with the board:
|
||||
https://www.olimex.com/Products/ARM/JTAG/ARM-JTAG-20-10/
|
||||
|
||||
NOTE: When connecting the J-Link GDB server, the interface must be set to
|
||||
JTAG, not SWD as you might expect.
|
||||
|
||||
The RXD/TXD pins. PA0/U0RX and PA1/U0TX, can then support a Serial console
|
||||
using the appropriate TTL adapter (TTL to RS-232 or TTL to USB serial).
|
||||
|
||||
|
@ -36,6 +36,10 @@ Serial Console
|
||||
The on-board XDS110 Debugger provide a USB virtual serial console using
|
||||
UART0 (PA0/U0RX and PA1/U0TX).
|
||||
|
||||
A J-Link debugger is used (see below), then the RXD/TXD jumper pins can
|
||||
be used to support a serial console through appropriate TTL level adapater
|
||||
(RS-232 or USB serial).
|
||||
|
||||
LEDs and Buttons
|
||||
================
|
||||
|
||||
@ -114,20 +118,23 @@ Running from SRAM
|
||||
Using J-Link
|
||||
============
|
||||
|
||||
Reference https://wiki.segger.com/CC1310_LaunchPad (for CC1310)
|
||||
Reference https://wiki.segger.com/CC1310_LaunchPad (for the CC1310 but also
|
||||
applies to the CC1312R1):
|
||||
|
||||
When shipped, the TI CC1312R1 LaunchPad evaluation board is configured to be
|
||||
used with the on-board debug probe. In order to use it with J-Link, the
|
||||
on-board debug probe needs to be isolated to make sure that it does not
|
||||
drive the debug signals. This can be done by removing some jumpers next
|
||||
to the XDS110 Out / CC1310 In connector [RXD, TXD, RST, TMS, TCK, TDO, TDI,
|
||||
WDO]. After isolating the on-board probe, the CC1312R1 device can be
|
||||
debugged using J-Link. Please note, that the J-Link needs to be connected
|
||||
to the board using the CC1312R1 using the micro JTAG connector marked
|
||||
"Target In".
|
||||
SWO]. After isolating the on-board probe, the CC1312R1 device can be
|
||||
debugged using J-Link. The J-Link needs to be connected to the board
|
||||
using the micro JTAG connector marked "Target In".
|
||||
|
||||
NOTE: When connecting the J-Link, the interface must be set to JTAG, not
|
||||
SWD as you might expect.
|
||||
I use the Olimex ARM-JTAG-20-10 to interface with the board:
|
||||
https://www.olimex.com/Products/ARM/JTAG/ARM-JTAG-20-10/
|
||||
|
||||
The RXD/TXD can then be used for a Serial console using the appropriate
|
||||
TTL adapter (TTL to RS-232 or TTL to USB serial).
|
||||
NOTE: When connecting the J-Link GDB server, the interface must be set to
|
||||
JTAG, not SWD as you might expect.
|
||||
|
||||
The RXD/TXD pins. PA0/U0RX and PA1/U0TX, can then support a Serial console
|
||||
using the appropriate TTL adapter (TTL to RS-232 or TTL to USB serial).
|
||||
|
@ -107,6 +107,19 @@
|
||||
|
||||
/* Button definitions *******************************************************/
|
||||
|
||||
/* The LaunchXL-CC1312R1 has two push-puttons:
|
||||
*
|
||||
* DIO13_BTN1 SW1 Low input sensed when depressed
|
||||
* DIO14_BTN2 SW2 Low input sensed when depressed
|
||||
*/
|
||||
|
||||
#define BUTTON_SW1 0
|
||||
#define BUTTON_SW2 1
|
||||
#define NUM_BUTTONS 2
|
||||
|
||||
#define BUTTON_SW1_BIT (1 << BUTTON_SW1)
|
||||
#define BUTTON_SW2_BIT (1 << BUTTON_SW2)
|
||||
|
||||
/* Pin configuration ********************************************************/
|
||||
|
||||
#ifdef CONFIG_TIVA_UART0
|
||||
|
@ -62,7 +62,8 @@
|
||||
|
||||
void board_autoled_initialize(void)
|
||||
{
|
||||
#warning Missing logic
|
||||
(void)tiva_configgpio(&g_gpio_gled);
|
||||
(void)tiva_configgpio(&g_gpio_rled);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -71,7 +72,55 @@ void board_autoled_initialize(void)
|
||||
|
||||
void board_autoled_on(int led)
|
||||
{
|
||||
#warning Missing logic
|
||||
bool gled_change = true; /* True: Change GLED */
|
||||
bool gled_on = false; /* High output illuminates */
|
||||
bool rled_on = false;
|
||||
|
||||
/* SYMBOL VAL MEANING GLED RLED
|
||||
* ---------------- --- ----------------------- ---- -----
|
||||
* LED_STARTED 0 NuttX has been started OFF OFF
|
||||
* LED_HEAPALLOCATE 1 Heap has been allocated OFF ON
|
||||
* LED_IRQSENABLED 1 Interrupts enabled OFF ON
|
||||
* LED_STACKCREATED 2 Idle stack created ON OFF
|
||||
* LED_INIRQ 3 In an interrupt N/C GLOW
|
||||
* LED_SIGNAL 3 In a signal handler N/C GLOW
|
||||
* LED_ASSERTION 3 An assertion failed N/C GLOW
|
||||
* LED_PANIC 4 The system has crashed OFF BLINK
|
||||
*/
|
||||
|
||||
switch (led)
|
||||
{
|
||||
case 0: /* GLED=OFF RLED=OFF */
|
||||
break;
|
||||
|
||||
case 3: /* GLED=N/C RLED=ON */
|
||||
gled_change = false;
|
||||
|
||||
/* Fall through */
|
||||
|
||||
case 1: /* GLED=OFF RLED=ON */
|
||||
case 4: /* GLED=OFF RLED=ON */
|
||||
rled_on = true;
|
||||
break;
|
||||
|
||||
case 2: /* GLED=ON RLED=OFF */
|
||||
gled_on = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set the new state of the GLED (unless is is N/C) */
|
||||
|
||||
if (gled_change)
|
||||
{
|
||||
tiva_gpiowrite(&g_gpio_gled, gled_on);
|
||||
}
|
||||
|
||||
/* Set the new state of the RLED */
|
||||
|
||||
tiva_gpiowrite(&g_gpio_rled, rled_on);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -80,7 +129,35 @@ void board_autoled_on(int led)
|
||||
|
||||
void board_autoled_off(int led)
|
||||
{
|
||||
#warning Missing logic
|
||||
/* SYMBOL VAL MEANING GLED RLED
|
||||
* ---------------- --- ----------------------- ---- -----
|
||||
* LED_STARTED 0 NuttX has been started OFF OFF
|
||||
* LED_HEAPALLOCATE 1 Heap has been allocated OFF ON
|
||||
* LED_IRQSENABLED 1 Interrupts enabled OFF ON
|
||||
* LED_STACKCREATED 2 Idle stack created ON OFF
|
||||
* LED_INIRQ 3 In an interrupt N/C GLOW
|
||||
* LED_SIGNAL 3 In a signal handler N/C GLOW
|
||||
* LED_ASSERTION 3 An assertion failed N/C GLOW
|
||||
* LED_PANIC 4 The system has crashed OFF BLINK
|
||||
*/
|
||||
|
||||
switch (led)
|
||||
{
|
||||
case 4: /* GLED=OFF RLED=OFF */
|
||||
tiva_gpiowrite(&g_gpio_gled, false);
|
||||
|
||||
/* Fall through */
|
||||
|
||||
case 3: /* GLED=N/C RLED=OFF */
|
||||
tiva_gpiowrite(&g_gpio_rled, false);
|
||||
break;
|
||||
|
||||
case 0: /* Should not happen */
|
||||
case 1: /* Should not happen */
|
||||
case 2: /* Should not happen */
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ARCH_LEDS */
|
||||
|
@ -72,7 +72,8 @@
|
||||
|
||||
void board_button_initialize(void)
|
||||
{
|
||||
#warning Missing logic
|
||||
(void)tiva_configgpio(&g_gpio_sw1);
|
||||
(void)tiva_configgpio(&g_gpio_sw2);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -88,8 +89,21 @@ void board_button_initialize(void)
|
||||
|
||||
uint32_t board_buttons(void)
|
||||
{
|
||||
#warning Missing logic
|
||||
return 0;
|
||||
uint32_t ret = 0;
|
||||
|
||||
/* When the button is pressed, a low value will be sensed */
|
||||
|
||||
if (!tiva_gpioread(&g_gpio_sw1))
|
||||
{
|
||||
ret |= BUTTON_SW1_BIT;
|
||||
}
|
||||
|
||||
if (!tiva_gpioread(&g_gpio_sw2))
|
||||
{
|
||||
ret |= BUTTON_SW2_BIT;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -107,45 +121,49 @@ uint32_t board_buttons(void)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_TIVA_GPIOP_IRQS)
|
||||
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_TIVA_GPIOIRQS)
|
||||
int board_button_irq(int id, xcpt_t irqhandler, FAR void *arg)
|
||||
{
|
||||
#if 0
|
||||
irqstate_t flags;
|
||||
int ret = -EINVAL;
|
||||
int irq;
|
||||
int ret;
|
||||
|
||||
/* Interrupts are supported only on ports P and Q and, hence, only on button SW4 */
|
||||
|
||||
if (id == BUTTON_SW4)
|
||||
if (id == BUTTON_SW1)
|
||||
{
|
||||
/* The following should be atomic */
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Detach and disable the button interrupt */
|
||||
|
||||
up_disable_irq(IRQ_SW4);
|
||||
irq_detach(IRQ_SW4);
|
||||
|
||||
/* Attach the new handler if so requested */
|
||||
|
||||
if (irqhandler != NULL)
|
||||
{
|
||||
ret = irq_attach(IRQ_SW4, irqhandler, arg);
|
||||
if (ret == OK)
|
||||
{
|
||||
up_enable_irq(IRQ_SW4);
|
||||
}
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
irq = CC1312_SW1_IRQ;
|
||||
}
|
||||
else if (id == BUTTON_SW2)
|
||||
{
|
||||
irq = CC1312_SW2_IRQ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -EINVAL
|
||||
}
|
||||
|
||||
/* The following should be atomic */
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Detach and disable the button interrupt */
|
||||
|
||||
up_disable_irq(irq);
|
||||
irq_detach(irq);
|
||||
|
||||
/* Attach the new handler if so requested */
|
||||
|
||||
ret = OK;
|
||||
if (irqhandler != NULL)
|
||||
{
|
||||
ret = irq_attach(irq, irqhandler, arg);
|
||||
if (ret == OK)
|
||||
{
|
||||
up_enable_irq(irq);
|
||||
}
|
||||
}
|
||||
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
#else
|
||||
#warning Missing logic
|
||||
return -ENOSYS;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -65,4 +65,71 @@ const struct cc13xx_pinconfig_s g_gpio_uart0_tx =
|
||||
.gpio = GPIO_DIO(1),
|
||||
.ioc = IOC_IOCFG_PORTID(IOC_IOCFG_PORTID_UART0_TX) | IOC_STD_OUTPUT
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* The LaunchXL-cc1312R1 and two LEDs controlled by software: DIO7_GLED (CR1)
|
||||
* and DIO6_RLED (CR2). A high output value illuminates an LED.
|
||||
*
|
||||
* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in
|
||||
* any way. The following definitions are used to access individual LEDs.
|
||||
*/
|
||||
|
||||
const struct cc13xx_pinconfig_s g_gpio_gled =
|
||||
{
|
||||
.gpio = GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_DIO(7),
|
||||
.ioc = IOC_IOCFG_PORTID(IOC_IOCFG_PORTID_GPIO) | IOC_STD_INPUT
|
||||
};
|
||||
|
||||
const struct cc13xx_pinconfig_s g_gpio_rled =
|
||||
{
|
||||
.gpio = GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_DIO(6),
|
||||
.ioc = IOC_IOCFG_PORTID(IOC_IOCFG_PORTID_GPIO) | IOC_STD_INPUT
|
||||
};
|
||||
|
||||
#ifdef CONFIG_ARCH_BUTTONS
|
||||
/* The LaunchXL-CC1312R1 has two push-puttons:
|
||||
*
|
||||
* DIO13_BTN1 SW1 Low input sensed when depressed
|
||||
* DIO14_BTN2 SW2 Low input sensed when depressed
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
/* Like IOC_STD_OUTPUT but with MCU wake-up enable and interrupt edge
|
||||
* detection enabled on both edges.
|
||||
*/
|
||||
|
||||
#define IOC_CC1312_BUTTON_OUTPUT (IOC_IOCFG_IOEV_MCU_WUEN | \
|
||||
IOC_IOCFG_IOSTR_AUTO | \
|
||||
IOC_IOCFG_IOCURR_2MA | \
|
||||
IOC_IOCFG_PULLCTL_DIS | \
|
||||
IOC_IOCFG_EDGEDET_BOTH | \
|
||||
IOC_IOCFG_EDGE_IRQEN | \
|
||||
IOC_IOCFG_IOMODE_NORMAL | \
|
||||
IOC_IOCFG_WUCFG_WAKEUPL | \
|
||||
IOC_IOCFG_IE)
|
||||
|
||||
#else
|
||||
/* Like IOC_STD_OUTPUT but with MCU wake-up enable. */
|
||||
|
||||
#define IOC_CC1312_BUTTON_OUTPUT (IOC_IOCFG_IOEV_MCU_WUEN | \
|
||||
IOC_IOCFG_IOSTR_AUTO | \
|
||||
IOC_IOCFG_IOCURR_2MA | \
|
||||
IOC_IOCFG_PULLCTL_DIS | \
|
||||
IOC_IOCFG_EDGEDET_NONE | \
|
||||
IOC_IOCFG_IOMODE_NORMAL | \
|
||||
IOC_IOCFG_WUCFG_WAKEUPL | \
|
||||
IOC_IOCFG_IE)
|
||||
#endif /* CONFIG_ARCH_IRQBUTTONS */
|
||||
|
||||
const struct cc13xx_pinconfig_s g_gpio_sw1 =
|
||||
{
|
||||
.gpio = GPIO_DIO(14),
|
||||
.ioc = IOC_IOCFG_PORTID(IOC_IOCFG_PORTID_GPIO) | IOC_CC1312_BUTTON_OUTPUT
|
||||
};
|
||||
|
||||
const struct cc13xx_pinconfig_s g_gpio_sw2 =
|
||||
{
|
||||
.gpio = GPIO_DIO(15),
|
||||
.ioc = IOC_IOCFG_PORTID(IOC_IOCFG_PORTID_GPIO) | IOC_CC1312_BUTTON_OUTPUT
|
||||
};
|
||||
#endif /* CONFIG_ARCH_BUTTONS */
|
||||
|
@ -58,7 +58,8 @@
|
||||
|
||||
void board_userled_initialize(void)
|
||||
{
|
||||
#warning Missing logic
|
||||
(void)tiva_configgpio(&g_gpio_gled);
|
||||
(void)tiva_configgpio(&g_gpio_rled);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -67,7 +68,22 @@ void board_userled_initialize(void)
|
||||
|
||||
void board_userled(int led, bool ledon)
|
||||
{
|
||||
#warning Missing logic
|
||||
const struct cc13xx_pinconfig_s *pinconfig;
|
||||
|
||||
if (led == BOARD_GLED)
|
||||
{
|
||||
pinconfig = &g_gpio_gled;
|
||||
}
|
||||
else if (led = BOARD_RLED)
|
||||
{
|
||||
pinconfig = &g_gpio_rled;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tiva_gpiowrite(pinconfig, ledon); /* High output illuminates */
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -76,5 +92,6 @@ void board_userled(int led, bool ledon)
|
||||
|
||||
void board_userled_all(uint8_t ledset)
|
||||
{
|
||||
#warning Missing logic
|
||||
board_userled(BOARD_GLED, (ledset & BOARD_GLED_BIT) != 0);
|
||||
board_userled(BOARD_RLED, (ledset & BOARD_RLED_BIT) != 0);
|
||||
}
|
||||
|
@ -46,6 +46,40 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Button GPIO IRQ numbers
|
||||
*
|
||||
* DIO13_BTN1 SW1 Low input sensed when depressed
|
||||
* DIO14_BTN2 SW2 Low input sensed when depressed
|
||||
*/
|
||||
|
||||
#define CC1312_SW1_IRQ TIVA_IRQ_DIO_13
|
||||
#define CC1312_SW2_IRQ TIVA_IRQ_DIO_14
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
struct cc13xx_pinconfig_s; /* Forward reference */
|
||||
|
||||
/* The LaunchXL-cc1312R1 and two LEDs controlled by software: DIO7_GLED (CR1)
|
||||
* and DIO6_RLED (CR2). A high output value illuminates an LED.
|
||||
*
|
||||
* If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in
|
||||
* any way. The following definitions are used to access individual LEDs.
|
||||
*/
|
||||
|
||||
extern const struct cc13xx_pinconfig_s g_gpio_gled;
|
||||
extern const struct cc13xx_pinconfig_s g_gpio_rled;
|
||||
|
||||
/* The LaunchXL-CC1312R1 has two push-puttons:
|
||||
*
|
||||
* DIO13_BTN1 SW1 Low input sensed when depressed
|
||||
* DIO14_BTN2 SW2 Low input sensed when depressed
|
||||
*/
|
||||
|
||||
extern const struct cc13xx_pinconfig_s g_gpio_sw1;
|
||||
extern const struct cc13xx_pinconfig_s g_gpio_sw2;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
@ -122,6 +122,7 @@
|
||||
* PJ1 USR_SW2
|
||||
* --- ------------
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ARCH_IRQBUTTONS
|
||||
# define GPIO_SW1 (GPIO_FUNC_INTERRUPT | GPIO_INT_BOTHEDGES | \
|
||||
GPIO_STRENGTH_2MA | GPIO_PADTYPE_STDWPU | \
|
||||
|
Loading…
Reference in New Issue
Block a user