Add LED support for the CC3200 Launchpad. From Jim Ewing
This commit is contained in:
parent
47b1d64d9f
commit
9e990b4cbe
@ -117,19 +117,11 @@
|
||||
#define PIN_63 0x0000003E
|
||||
#define PIN_64 0x0000003F
|
||||
|
||||
/************************************************************************************
|
||||
* Private Data
|
||||
************************************************************************************/
|
||||
#define GPIO_O_GPIO_DATA 0x00000000
|
||||
#define GPIO_O_GPIO_DIR 0x00000400
|
||||
|
||||
static const unsigned long g_cc3200_pinmap[64] =
|
||||
{
|
||||
10, 11, 12, 13, 14, 15, 16, 17, 255, 255, 18,
|
||||
19, 20, 21, 22, 23, 24, 40, 28, 29, 25, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
31, 255, 255, 255, 255, 0, 255, 32, 30, 255, 1,
|
||||
255, 2, 3, 4, 5, 6, 7, 8, 9
|
||||
};
|
||||
#define GPIO_DIR_MODE_OUT 0x00000001
|
||||
#define GPIO_DIR_MODE_IN 0x00000000
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
@ -139,5 +131,9 @@ void cc3200_print(char* str);
|
||||
void cc3200_pin_config_set(uint32_t pin, uint32_t pin_strength, uint32_t pin_type);
|
||||
void cc3200_pin_mode_set(uint32_t pin, uint32_t pin_mode);
|
||||
void cc3200_pin_type_uart(uint32_t pin, uint32_t pin_mode);
|
||||
void cc3200_get_gpio_port_pin(uint8_t pin, uint32_t *gpio_port, uint8_t *gpio_pin);
|
||||
void cc3200_set_gpio(uint8_t pin, uint32_t gpio_port, uint8_t gpio_pin, uint8_t gpio_val);
|
||||
void cc3200_set_gpio_dir(uint32_t port, uint8_t pins, uint32_t pin_io);
|
||||
void cc3200_pin_type_gpio(uint32_t pin, uint32_t pin_mode, uint32_t open_drain);
|
||||
|
||||
#endif /* __CONFIGS_CC3200_INCLUDE_UTILS_H */
|
||||
|
@ -211,7 +211,7 @@ CONFIG_ARCH_BOARD="cc3200-launchpad"
|
||||
# Common Board Options
|
||||
#
|
||||
CONFIG_ARCH_HAVE_LEDS=y
|
||||
# CONFIG_ARCH_LEDS is not set
|
||||
CONFIG_ARCH_LEDS=y
|
||||
CONFIG_ARCH_HAVE_BUTTONS=y
|
||||
# CONFIG_ARCH_BUTTONS is not set
|
||||
CONFIG_ARCH_HAVE_IRQBUTTONS=y
|
||||
@ -249,6 +249,7 @@ CONFIG_PREALLOC_TIMERS=2
|
||||
#
|
||||
# Tasks and Scheduling
|
||||
#
|
||||
# CONFIG_INIT_NONE is not set
|
||||
CONFIG_INIT_ENTRYPOINT=y
|
||||
# CONFIG_INIT_FILEPATH is not set
|
||||
CONFIG_USER_ENTRYPOINT="nsh_main"
|
||||
|
@ -40,8 +40,7 @@ CFLAGS += -I$(TOPDIR)/sched -I../include
|
||||
|
||||
ASRCS =
|
||||
AOBJS = $(ASRCS:.S=$(OBJEXT))
|
||||
CSRCS = cc3200_boot.c cc3200_serial.c cc3200_utils.c
|
||||
#cc3200_leds.c
|
||||
CSRCS = cc3200_boot.c cc3200_serial.c cc3200_utils.c cc3200_leds.c
|
||||
|
||||
ifeq ($(CONFIG_ARCH_LEDS),y)
|
||||
CSRCS += cc3200_autoleds.c
|
||||
|
@ -72,10 +72,10 @@
|
||||
* briefly while the assertion is handled. You will probably never see this.
|
||||
*
|
||||
* Flashing RED:
|
||||
* - In the event of a fatal crash, the BLUE and GREEN components will be
|
||||
* - In the event of a fatal crash, the YELLOW and GREEN components will be
|
||||
* extinguished and the RED component will FLASH at a 2Hz rate.
|
||||
*
|
||||
* RED GREEN BLUE
|
||||
* RED YELLOW BLUE
|
||||
* LED_STARTED 0 OFF OFF OFF
|
||||
* LED_HEAPALLOCATE 0 OFF OFF OFF
|
||||
* LED_IRQSENABLED 0 OFF OFF OFF
|
||||
@ -135,7 +135,38 @@
|
||||
|
||||
void board_led_on(int led)
|
||||
{
|
||||
// cc3200_ledon(led);
|
||||
switch (led)
|
||||
{
|
||||
/* All components stay off until the file initialization step */
|
||||
|
||||
default:
|
||||
case 0:
|
||||
break;
|
||||
|
||||
/* The GREEN component is illuminated at the final initialization step */
|
||||
|
||||
case 1:
|
||||
cc3200_ledon(1);
|
||||
break;
|
||||
|
||||
/* These will illuminate the YELLOW component with on effect no RED and GREEN */
|
||||
|
||||
case 2:
|
||||
cc3200_ledon(2);
|
||||
break;
|
||||
|
||||
/* This will turn off YELLOW and GREEN and turn RED on */
|
||||
|
||||
case 4:
|
||||
cc3200_ledoff(1);
|
||||
cc3200_ledoff(2);
|
||||
|
||||
/* This will illuminate the RED component with no effect on YELLOW and GREEN */
|
||||
|
||||
case 3:
|
||||
cc3200_ledon(3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -144,7 +175,28 @@ void board_led_on(int led)
|
||||
|
||||
void board_led_off(int led)
|
||||
{
|
||||
// cc3200_ledoff(led);
|
||||
switch (led)
|
||||
{
|
||||
/* These should not happen and are ignored */
|
||||
|
||||
default:
|
||||
case 0:
|
||||
case 1:
|
||||
break;
|
||||
|
||||
/* These will extinguish the YELLOW component with no effect on RED and GREEN */
|
||||
|
||||
case 2:
|
||||
cc3200_ledoff(2);
|
||||
break;
|
||||
|
||||
/* These will extinguish the RED component with on effect on RED and GREEN */
|
||||
|
||||
case 3:
|
||||
case 4:
|
||||
cc3200_ledoff(3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ARCH_LEDS */
|
||||
|
@ -103,7 +103,7 @@ void tiva_boardinitialize(void)
|
||||
|
||||
cc3200_print("\r\nCC3200 init\r\n");
|
||||
|
||||
// cc3200_ledinit();
|
||||
cc3200_ledinit();
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
|
@ -65,4 +65,22 @@ void cc3200_init(void);
|
||||
|
||||
void cc3200_uart_init(void);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: cc3200_led_init
|
||||
************************************************************************************/
|
||||
|
||||
void cc3200_led_init(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cc3200_ledon
|
||||
****************************************************************************/
|
||||
|
||||
void cc3200_ledon(int led);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cc3200_ledoff
|
||||
****************************************************************************/
|
||||
|
||||
void cc3200_ledoff(int led);
|
||||
|
||||
#endif /* __CONFIGS_CC3200_LAUNCHPAD_SRC_CC3200_LAUNCHPAD_H */
|
||||
|
156
configs/cc3200-launchpad/src/cc3200_leds.c
Normal file
156
configs/cc3200-launchpad/src/cc3200_leds.c
Normal file
@ -0,0 +1,156 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#include <chip/cc3200_memorymap.h>
|
||||
|
||||
#include "up_arch.h"
|
||||
|
||||
#include "cc3200_launchpad.h"
|
||||
#include "cc3200_utils.h"
|
||||
|
||||
#define LED1_GPIO 9
|
||||
#define LED2_GPIO 10
|
||||
#define LED3_GPIO 11
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cc3200_ledinit
|
||||
****************************************************************************/
|
||||
|
||||
void cc3200_ledinit(void)
|
||||
{
|
||||
|
||||
uint32_t led1_port;
|
||||
uint8_t led1_pin;
|
||||
uint32_t led2_port;
|
||||
uint8_t led2_pin;
|
||||
uint32_t led3_port;
|
||||
uint8_t led3_pin;
|
||||
uint8_t x=16;
|
||||
|
||||
putreg32(getreg32(0x44025000 + 0x00000058) | 0x00000001, 0x44025000 + 0x00000058);
|
||||
while(--x)
|
||||
;
|
||||
|
||||
cc3200_pin_type_gpio(PIN_01, PIN_MODE_0, false);
|
||||
cc3200_set_gpio_dir(TIVA_GPIOB_BASE, 0x4, GPIO_DIR_MODE_OUT);
|
||||
|
||||
cc3200_pin_type_gpio(PIN_02, PIN_MODE_0, false);
|
||||
cc3200_set_gpio_dir(TIVA_GPIOB_BASE, 0x8, GPIO_DIR_MODE_OUT);
|
||||
|
||||
cc3200_pin_type_gpio(PIN_64, PIN_MODE_0, false);
|
||||
cc3200_set_gpio_dir(TIVA_GPIOB_BASE, 0x2, GPIO_DIR_MODE_OUT);
|
||||
|
||||
cc3200_get_gpio_port_pin(LED1_GPIO, &led1_port, &led1_pin);
|
||||
cc3200_get_gpio_port_pin(LED2_GPIO, &led2_port, &led2_pin);
|
||||
cc3200_get_gpio_port_pin(LED3_GPIO, &led3_port, &led3_pin);
|
||||
|
||||
cc3200_set_gpio(LED1_GPIO, led1_port, led1_pin, 0);
|
||||
cc3200_set_gpio(LED2_GPIO, led2_port, led2_pin, 0);
|
||||
cc3200_set_gpio(LED3_GPIO, led3_port, led3_pin, 0);
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cc3200_ledon
|
||||
****************************************************************************/
|
||||
|
||||
void cc3200_ledon(int led)
|
||||
{
|
||||
unsigned int led1_port;
|
||||
unsigned char led1_pin;
|
||||
unsigned int led2_port;
|
||||
unsigned char led2_pin;
|
||||
unsigned int led3_port;
|
||||
unsigned char led3_pin;
|
||||
|
||||
cc3200_get_gpio_port_pin(LED1_GPIO, &led1_port, &led1_pin);
|
||||
cc3200_get_gpio_port_pin(LED2_GPIO, &led2_port, &led2_pin);
|
||||
cc3200_get_gpio_port_pin(LED3_GPIO, &led3_port, &led3_pin);
|
||||
|
||||
switch (led)
|
||||
{
|
||||
/* All */
|
||||
|
||||
default:
|
||||
case 0:
|
||||
cc3200_set_gpio(LED1_GPIO, led1_port, led1_pin, 1);
|
||||
cc3200_set_gpio(LED2_GPIO, led2_port, led2_pin, 1);
|
||||
cc3200_set_gpio(LED3_GPIO, led3_port, led3_pin, 1);
|
||||
break;
|
||||
|
||||
/* GREEN */
|
||||
|
||||
case 1:
|
||||
cc3200_set_gpio(LED3_GPIO, led3_port, led3_pin, 1);
|
||||
break;
|
||||
|
||||
/* YELLOW */
|
||||
|
||||
case 2:
|
||||
cc3200_set_gpio(LED2_GPIO, led2_port, led2_pin, 1);
|
||||
break;
|
||||
|
||||
/* RED */
|
||||
|
||||
case 3:
|
||||
cc3200_set_gpio(LED1_GPIO, led1_port, led1_pin, 1);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cc3200_ledoff
|
||||
****************************************************************************/
|
||||
|
||||
void cc3200_ledoff(int led)
|
||||
{
|
||||
|
||||
unsigned int led1_port;
|
||||
unsigned char led1_pin;
|
||||
unsigned int led2_port;
|
||||
unsigned char led2_pin;
|
||||
unsigned int led3_port;
|
||||
unsigned char led3_pin;
|
||||
|
||||
cc3200_get_gpio_port_pin(LED1_GPIO, &led1_port, &led1_pin);
|
||||
cc3200_get_gpio_port_pin(LED2_GPIO, &led2_port, &led2_pin);
|
||||
cc3200_get_gpio_port_pin(LED3_GPIO, &led3_port, &led3_pin);
|
||||
|
||||
switch (led)
|
||||
{
|
||||
/* All */
|
||||
|
||||
default:
|
||||
case 0:
|
||||
cc3200_set_gpio(LED1_GPIO, led1_port, led1_pin, 0);
|
||||
cc3200_set_gpio(LED2_GPIO, led2_port, led2_pin, 0);
|
||||
cc3200_set_gpio(LED3_GPIO, led3_port, led3_pin, 0);
|
||||
break;
|
||||
|
||||
/* GREEN */
|
||||
|
||||
case 1:
|
||||
cc3200_set_gpio(LED3_GPIO, led3_port, led3_pin, 0);
|
||||
break;
|
||||
|
||||
/* YELLOW */
|
||||
|
||||
case 2:
|
||||
cc3200_set_gpio(LED2_GPIO, led2_port, led2_pin, 0);
|
||||
break;
|
||||
|
||||
/* RED */
|
||||
|
||||
case 3:
|
||||
cc3200_set_gpio(LED1_GPIO, led1_port, led1_pin, 0);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
@ -38,16 +38,71 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <arch/board/cc3200_utils.h>
|
||||
#include <chip/cc3200_memorymap.h>
|
||||
|
||||
#include "nuttx/arch.h"
|
||||
#include "up_arch.h"
|
||||
|
||||
#include "cc3200_launchpad.h"
|
||||
#include "cc3200_utils.h"
|
||||
|
||||
/************************************************************************************
|
||||
* Private Data
|
||||
************************************************************************************/
|
||||
|
||||
static const unsigned long g_cc3200_pinmap[64] =
|
||||
{
|
||||
10, 11, 12, 13, 14, 15, 16, 17, 255, 255, 18,
|
||||
19, 20, 21, 22, 23, 24, 40, 28, 29, 25, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
|
||||
31, 255, 255, 255, 255, 0, 255, 32, 30, 255, 1,
|
||||
255, 2, 3, 4, 5, 6, 7, 8, 9
|
||||
};
|
||||
|
||||
static const unsigned long gpio_reg[]=
|
||||
{
|
||||
TIVA_GPIOA_BASE,
|
||||
TIVA_GPIOB_BASE,
|
||||
TIVA_GPIOC_BASE,
|
||||
TIVA_GPIOD_BASE
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: cc3200_get_gpio_port_pin
|
||||
************************************************************************************/
|
||||
|
||||
void cc3200_get_gpio_port_pin(uint8_t pin, uint32_t *gpio_port, uint8_t *gpio_pin)
|
||||
{
|
||||
*gpio_pin = 1 << (pin % 8);
|
||||
*gpio_port = (pin / 8);
|
||||
*gpio_port = gpio_reg[*gpio_port];
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: cc3200_set_gpio
|
||||
************************************************************************************/
|
||||
|
||||
void cc3200_set_gpio(uint8_t pin, uint32_t gpio_port, uint8_t gpio_pin,
|
||||
uint8_t gpio_val)
|
||||
{
|
||||
gpio_val = gpio_val << (pin % 8);
|
||||
putreg32(gpio_val, gpio_port + (gpio_pin << 2));
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: cc3200_set_gpio_dir
|
||||
************************************************************************************/
|
||||
|
||||
void cc3200_set_gpio_dir(uint32_t port, uint8_t pins, uint32_t pin_io)
|
||||
{
|
||||
putreg32(((pin_io & 1) ? (getreg32(port + GPIO_O_GPIO_DIR) | pins) :
|
||||
(getreg32(port + GPIO_O_GPIO_DIR) & ~(pins))), port + GPIO_O_GPIO_DIR);
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: cc3200_print
|
||||
************************************************************************************/
|
||||
@ -109,6 +164,24 @@ void cc3200_pin_type_uart(uint32_t pin, uint32_t pin_mode)
|
||||
cc3200_pin_config_set(pin, PIN_STRENGTH_2MA, PIN_TYPE_STD);
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: cc3200_pin_type_gpio
|
||||
************************************************************************************/
|
||||
|
||||
void cc3200_pin_type_gpio(uint32_t pin, uint32_t pin_mode, uint32_t open_drain)
|
||||
{
|
||||
if(open_drain)
|
||||
{
|
||||
cc3200_pin_config_set(pin, PIN_STRENGTH_2MA, PIN_TYPE_OD);
|
||||
}
|
||||
else
|
||||
{
|
||||
cc3200_pin_config_set(pin, PIN_STRENGTH_2MA, PIN_TYPE_STD);
|
||||
}
|
||||
|
||||
cc3200_pin_mode_set(pin, pin_mode);
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: cc3200_init
|
||||
************************************************************************************/
|
||||
@ -117,7 +190,7 @@ void cc3200_init(void)
|
||||
{
|
||||
uint8_t x=16;
|
||||
|
||||
putreg32(getreg32(0x4402F064) | 0x800000,0x4402F064);
|
||||
putreg32(getreg32(0x4402F064) | 0x800000, 0x4402F064);
|
||||
putreg32(getreg32(0x4402F800 + 0x00000418) | (1<<4), 0x4402F800 + 0x00000418);
|
||||
putreg32(getreg32(0x4402E16C) | 0x3C, 0x4402E16C);
|
||||
putreg32(getreg32(0x44025000 + 0x00000048) | 0x00000001, 0x44025000 + 0x00000048);
|
||||
|
Loading…
Reference in New Issue
Block a user