BSP430
20141115
Board Support Package for MSP430 microcontrollers
Main Page
Related Pages
Modules
Data Structures
Files
Examples
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
Bootstrapping a New Platform: Blink
The second bootstrap program confirms that you can control LEDs.
main.c
#include <
bsp430/platform.h
>
/* We're going to use LEDs so we need the interface file */
#include <
bsp430/utility/led.h
>
/* We want to know the nominal clock speed so we can delay. */
#include <
bsp430/clock.h
>
void
main ()
{
int
led = 0;
/* First thing you do in main is configure the platform.
* Note that this configures the LEDs. */
vBSP430platformInitialize_ni
();
while
(1) {
/* A common complaint is that "blink doesn't work!" when the issue
* is that the watchdog is resetting the board. Don't let that
* happen to you. */
BSP430_CORE_WATCHDOG_CLEAR
();
if
(1 <
nBSP430led
) {
/* If there are multiple LEDs, turn each LED on in turn, wait a
* half second, then turn it off and move to the next LED. If
* there's only one LED, the invert state handles the on as well
* as the off. */
vBSP430ledSet
(led, 1);
}
BSP430_CORE_DELAY_CYCLES
(
BSP430_CLOCK_NOMINAL_MCLK_HZ
/ 2);
/* -1 means "invert state", which in this case will turn it off */
vBSP430ledSet
(led, -1);
if
(++led ==
nBSP430led
) {
led = 0;
}
}
}
bsp430_config.h
/* Specify that we want the LED feature. Not strictly necessary,
* since this defaults to true. */
#define configBSP430_LED 1
/* Get the rest of the default configuration */
#include <
bsp430/platform/bsp430_config.h
>
Makefile
PLATFORM ?= exp430fr5739
MODULES=$(MODULES_PLATFORM)
SRC=main.c
include $(BSP430_ROOT)/make/Makefile.common
Generated on Sat Nov 15 2014 11:27:13 for BSP430 by
1.8.8