implemented hal_led.h for msp430 platforms

This commit is contained in:
Matthias Ringwald 2015-04-19 22:15:25 +02:00
parent 3061f5e68c
commit 30556247b7
15 changed files with 60 additions and 33 deletions

View File

@ -40,6 +40,7 @@ CORE = \
hal_cpu.c \ hal_cpu.c \
hal_board.c \ hal_board.c \
hal_compat.c \ hal_compat.c \
hal_led.c \
hal_usb.c \ hal_usb.c \
hci_dump.c \ hci_dump.c \
btstack_memory.c \ btstack_memory.c \

View File

@ -55,6 +55,7 @@
#include "btstack_memory.h" #include "btstack_memory.h"
#include <btstack/run_loop.h> #include <btstack/run_loop.h>
#include <btstack/hal_led.h>
#include "btstack-config.h" #include "btstack-config.h"
#define HEARTBEAT_PERIOD_MS 1000 #define HEARTBEAT_PERIOD_MS 1000
@ -74,7 +75,7 @@ static void heartbeat_handler(timer_source_t *ts){
printf(lineBuffer); printf(lineBuffer);
// toggle LED // toggle LED
LED_PORT_OUT = LED_PORT_OUT ^ LED_2; hal_led_toggle();
// re-register timer // re-register timer
run_loop_register_timer(ts, HEARTBEAT_PERIOD_MS); run_loop_register_timer(ts, HEARTBEAT_PERIOD_MS);

View File

@ -6,10 +6,15 @@
#ifndef HAL_BOARD_H #ifndef HAL_BOARD_H
#define HAL_BOARD_H #define HAL_BOARD_H
#define LED_PORT_DIR P1DIR // LED 1 = P1.0
#define LED_PORT_OUT P1OUT #define LED1_DIR P1DIR
#define LED_1 BIT0 #define LED1_OUT P1OUT
#define LED_2 BIT1 #define LED1_PIN BIT0
// LED 2 = P1.1
#define LED2_DIR P1DIR
#define LED2_OUT P1OUT
#define LED2_PIN BIT1
#define CLK_PORT_DIR P11DIR #define CLK_PORT_DIR P11DIR
#define CLK_PORT_OUT P11OUT #define CLK_PORT_OUT P11OUT

View File

@ -55,7 +55,7 @@ static uint8_t low_power_mode_for_sleep = LPM0_bits;
void hal_cpu_disable_irqs(){ void hal_cpu_disable_irqs(){
// LED off // LED off
LED_PORT_OUT &= ~LED_1; LED1_OUT &= ~LED1_PIN;
// disable irq // disable irq
__bic_SR_register(GIE); __bic_SR_register(GIE);
@ -67,16 +67,16 @@ void hal_cpu_enable_irqs(){
__bis_SR_register(GIE); __bis_SR_register(GIE);
// LED on // LED on
LED_PORT_OUT |= LED_1; LED1_OUT |= LED1_PIN;
} }
void hal_cpu_set_uart_needed_during_sleep(uint8_t enabled){ void hal_cpu_set_uart_needed_during_sleep(uint8_t enabled){
if (enabled){ if (enabled){
LED_PORT_OUT |= LED_2; LED2_OUT |= LED2_PIN;
low_power_mode_for_sleep = LPM0_bits; low_power_mode_for_sleep = LPM0_bits;
return; return;
} }
LED_PORT_OUT &= ~LED_2; LED2_OUT &= ~LED2_PIN;
low_power_mode_for_sleep = LPM3_bits; low_power_mode_for_sleep = LPM3_bits;
} }
@ -86,8 +86,7 @@ void hal_cpu_enable_irqs_and_sleep(){
__bis_SR_register(low_power_mode_for_sleep + GIE); __bis_SR_register(low_power_mode_for_sleep + GIE);
// LED on // LED on
P1OUT |= 1; LED1_OUT |= LED1_PIN;
} }

View File

@ -80,9 +80,11 @@ int main(void)
halUsbInit(); halUsbInit();
// init LEDs // init LEDs
LED_PORT_OUT |= LED_1 | LED_2; LED1_OUT |= LED1_PIN;
LED_PORT_DIR |= LED_1 | LED_2; LED1_DIR |= LED1_PIN;
LED2_OUT |= LED2_PIN;
LED2_DIR |= LED2_PIN;
/// GET STARTED with BTstack /// /// GET STARTED with BTstack ///
btstack_memory_init(); btstack_memory_init();
run_loop_init(RUN_LOOP_EMBEDDED); run_loop_init(RUN_LOOP_EMBEDDED);

View File

@ -39,6 +39,7 @@ CORE = \
hal_tick.c \ hal_tick.c \
hal_cpu.c \ hal_cpu.c \
hal_board.c \ hal_board.c \
hal_led.c \
hal_compat.c \ hal_compat.c \
hal_usb.c \ hal_usb.c \
hci_dump.c \ hci_dump.c \

View File

@ -61,6 +61,7 @@
#include "btstack_memory.h" #include "btstack_memory.h"
#include <btstack/run_loop.h> #include <btstack/run_loop.h>
#include <btstack/hal_led.h>
#include "btstack-config.h" #include "btstack-config.h"
#define HEARTBEAT_PERIOD_MS 1000 #define HEARTBEAT_PERIOD_MS 1000
@ -89,7 +90,7 @@ static void heartbeat_handler(timer_source_t *ts){
printf(lineBuffer); printf(lineBuffer);
// toggle LED // toggle LED
LED_PORT_OUT = LED_PORT_OUT ^ LED_2; hal_led_toggle();
// re-register timer // re-register timer
run_loop_register_timer(ts, HEARTBEAT_PERIOD_MS); run_loop_register_timer(ts, HEARTBEAT_PERIOD_MS);

View File

@ -6,10 +6,15 @@
#ifndef HAL_BOARD_H #ifndef HAL_BOARD_H
#define HAL_BOARD_H #define HAL_BOARD_H
#define LED_PORT_DIR P1DIR // LED 1 = P1.0
#define LED_PORT_OUT P1OUT #define LED1_DIR P1DIR
#define LED_1 BIT0 #define LED1_OUT P1OUT
#define LED_2 BIT1 #define LED1_PIN BIT0
// LED 2 = P1.1
#define LED2_DIR P1DIR
#define LED2_OUT P1OUT
#define LED2_PIN BIT1
#define CLK_PORT_DIR P11DIR #define CLK_PORT_DIR P11DIR
#define CLK_PORT_OUT P11OUT #define CLK_PORT_OUT P11OUT

View File

@ -55,7 +55,7 @@ static uint8_t low_power_mode_for_sleep = LPM0_bits;
void hal_cpu_disable_irqs(){ void hal_cpu_disable_irqs(){
// LED off // LED off
LED_PORT_OUT &= ~LED_1; LED1_OUT &= ~LED1_PIN;
// disable irq // disable irq
__bic_SR_register(GIE); __bic_SR_register(GIE);
@ -67,16 +67,16 @@ void hal_cpu_enable_irqs(){
__bis_SR_register(GIE); __bis_SR_register(GIE);
// LED on // LED on
LED_PORT_OUT |= LED_1; LED1_OUT |= LED1_PIN;
} }
void hal_cpu_set_uart_needed_during_sleep(uint8_t enabled){ void hal_cpu_set_uart_needed_during_sleep(uint8_t enabled){
if (enabled){ if (enabled){
LED_PORT_OUT |= LED_2; LED2_OUT |= LED2_PIN;
low_power_mode_for_sleep = LPM0_bits; low_power_mode_for_sleep = LPM0_bits;
return; return;
} }
LED_PORT_OUT &= ~LED_2; LED2_OUT &= ~LED2_PIN;
low_power_mode_for_sleep = LPM3_bits; low_power_mode_for_sleep = LPM3_bits;
} }
@ -86,8 +86,7 @@ void hal_cpu_enable_irqs_and_sleep(){
__bis_SR_register(low_power_mode_for_sleep + GIE); __bis_SR_register(low_power_mode_for_sleep + GIE);
// LED on // LED on
P1OUT |= 1; LED1_OUT |= LED1_PIN;
} }

View File

@ -75,8 +75,10 @@ static void hw_setup(){
halUsbInit(); halUsbInit();
// init LEDs // init LEDs
LED_PORT_OUT |= LED_1 | LED_2; LED1_OUT |= LED1_PIN;
LED_PORT_DIR |= LED_1 | LED_2; LED1_DIR |= LED1_PIN;
LED2_OUT |= LED2_PIN;
LED2_DIR |= LED2_PIN;
// ready - enable irq used in h4 task // ready - enable irq used in h4 task
__enable_interrupt(); __enable_interrupt();

View File

@ -0,0 +1,8 @@
#include <btstack/hal_led.h>
#include "hal_board.h"
#include <msp430.h>
void hal_led_toggle(void){
LED2_OUT = LED2_OUT ^ LED2_PIN;
}

View File

@ -45,6 +45,7 @@ CORE = \
utils.c \ utils.c \
main.c \ main.c \
hal_board.c \ hal_board.c \
hal_led.c \
hal_usb.c \ hal_usb.c \
hal_tick.c \ hal_tick.c \
run_loop.c \ run_loop.c \

View File

@ -55,6 +55,7 @@
#include "btstack_memory.h" #include "btstack_memory.h"
#include <btstack/run_loop.h> #include <btstack/run_loop.h>
#include <btstack/hal_led.h>
#include "btstack-config.h" #include "btstack-config.h"
#define HEARTBEAT_PERIOD_MS 1000 #define HEARTBEAT_PERIOD_MS 1000
@ -74,7 +75,7 @@ static void heartbeat_handler(timer_source_t *ts){
printf(lineBuffer); printf(lineBuffer);
// toggle LED // toggle LED
LED2_OUT = LED2_OUT ^ LED2_PIN; hal_led_toggle();
// re-register timer // re-register timer
run_loop_register_timer(ts, HEARTBEAT_PERIOD_MS); run_loop_register_timer(ts, HEARTBEAT_PERIOD_MS);

View File

@ -86,8 +86,7 @@ void hal_cpu_enable_irqs_and_sleep(){
__bis_SR_register(low_power_mode_for_sleep + GIE); __bis_SR_register(low_power_mode_for_sleep + GIE);
// LED on // LED on
P1OUT |= 1; LED1_OUT |= LED1_PIN;
} }

View File

@ -78,9 +78,11 @@ static void hw_setup(){
hal_tick_init(); hal_tick_init();
/// init LEDs // init LEDs
LED1_DIR |= LED1_PIN; LED1_OUT |= LED1_PIN;
LED2_DIR |= LED2_PIN; LED1_DIR |= LED1_PIN;
LED2_OUT |= LED2_PIN;
LED2_DIR |= LED2_PIN;
// ready - enable irq used in h4 task // ready - enable irq used in h4 task
__enable_interrupt(); __enable_interrupt();