mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-23 20:59:42 +02:00
70 lines
1.3 KiB
C
70 lines
1.3 KiB
C
/*
|
|
* Test code for the Tornado CPU board
|
|
*/
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
|
|
extern uint32_t _data_flash;
|
|
extern uint32_t _data_begin;
|
|
extern uint32_t _data_end;
|
|
extern uint32_t _bss_end;
|
|
extern uint32_t _stack_end;
|
|
extern uint32_t _neg_stack_end;
|
|
|
|
|
|
#define IOCONFIG 0x40044000
|
|
#define GPIO_BASE_0 0x50000000
|
|
#define GPIO0DATA (GPIO_BASE_0+0x3ffc)
|
|
#define GPIO0DIR (GPIO_BASE_0+0x8000)
|
|
|
|
/* LED is on PIO0_5 */
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
{
|
|
volatile uint32_t *data = (void *) GPIO0DATA;
|
|
volatile uint32_t *dir = (void *) GPIO0DIR;
|
|
uint32_t mask = 0;
|
|
uint32_t loop;
|
|
|
|
*dir = 1 << 5;
|
|
|
|
while (1) {
|
|
*data = mask;
|
|
mask ^= 1 << 5;
|
|
for (loop = 100000; loop; loop--);
|
|
}
|
|
}
|
|
|
|
|
|
void __attribute__((naked, section(".init"))) __init(void)
|
|
{
|
|
register uint32_t *t = &_data_begin;
|
|
register uint32_t *s = &_data_flash;
|
|
|
|
while (t != &_data_end)
|
|
*t++ = *s++;
|
|
while (t != &_bss_end)
|
|
*t++ = 0;
|
|
main(0, NULL);
|
|
}
|
|
|
|
|
|
#define INITIAL_SP ((uint32_t) &_stack_end)
|
|
#define NEG_INITIAL_SP ((uint32_t) &_neg_stack_end)
|
|
#define VECTORS 8
|
|
|
|
|
|
uint32_t __vectors[VECTORS] __attribute__((section(".vectors"))) = {
|
|
INITIAL_SP, /* initial SP value @@@ */
|
|
VECTORS*4+1, /* reset */
|
|
0, /* NMI */
|
|
0, /* HardFault */
|
|
0, /* reserved */
|
|
0, /* reserved */
|
|
0, /* reserved */
|
|
NEG_INITIAL_SP-(VECTORS*4+1),/* checksum */
|
|
};
|