msp430 with minimized low level init code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* main.cpp | |
* | |
* Created on: Mar 15, 2012 | |
* Author: kimballr | |
*/ | |
#include <msp430.h> | |
#define GREEN_LED_PIN BIT6 | |
#define RED_LED_PIN BIT0 | |
#define OUTPUT_SMCLK_PIN BIT4 | |
static void init() { | |
P1OUT = RED_LED_PIN; // start with the red led lit | |
P1DIR = GREEN_LED_PIN | RED_LED_PIN | OUTPUT_SMCLK_PIN; | |
P1SEL |= OUTPUT_SMCLK_PIN; | |
} | |
static void loop() { | |
do { | |
P1OUT ^= GREEN_LED_PIN | RED_LED_PIN; | |
__delay_cycles(128000); | |
} while(1); | |
} | |
int main(void) { | |
init(); | |
do { | |
loop(); | |
} while(1); | |
} | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
/** | |
* override the lowlevel initialization | |
*/ | |
__attribute__((naked,section(".init2"))) void __init_stack(void) { | |
asm("mov #__stack, r1\n"); | |
} | |
/** | |
* __low_level_init() - simple replacement routine just do a WDT stop | |
* | |
*/ | |
__attribute__((naked,section(".init3"))) void __low_level_init(void) { | |
WDTCTL = WDTHOLD + WDTPW; | |
} | |
/** | |
* __do_copy_data() - empty replacement when no data | |
*/ | |
__attribute__((naked,section(".init3"))) void __do_copy_data(void) { | |
; // nothing | |
} | |
/** | |
* __do_copy_bss() - empty replacement when no bss | |
*/ | |
__attribute__((naked,section(".init3"))) void __do_clear_bss(void) { | |
; // nothing | |
} | |
#ifdef __cplusplus | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment