-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.h
More file actions
65 lines (56 loc) · 1.84 KB
/
Copy pathmain.h
File metadata and controls
65 lines (56 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
typedef unsigned long uint32_t;
typedef unsigned char uint8_t;
#define FLASH_BASE 0x08000000ul
#define SRAM_BASE 0x20000000ul
#define PERIPH_BASE 0x40000000ul
#define SRAM_SIZE 128ul*1024ul
#define SRAM_END (SRAM_BASE + SRAM_SIZE)
#define APB1PERIPH_BASE PERIPH_BASE
#define APB2PERIPH_BASE (PERIPH_BASE + 0x00010000UL)
#define AHB1PERIPH_BASE (PERIPH_BASE + 0x00020000UL)
#define AHB2PERIPH_BASE (PERIPH_BASE + 0x10000000UL)
#define GPIOA_BASE (AHB1PERIPH_BASE + 0x0000UL)
#define GPIOB_BASE (AHB1PERIPH_BASE + 0x0400UL)
#define GPIOC_BASE (AHB1PERIPH_BASE + 0x0800UL)
#define GPIOD_BASE (AHB1PERIPH_BASE + 0x0C00UL)
#define GPIOE_BASE (AHB1PERIPH_BASE + 0x1000UL)
#define GPIOF_BASE (AHB1PERIPH_BASE + 0x1400UL)
#define GPIOG_BASE (AHB1PERIPH_BASE + 0x1800UL)
#define GPIOH_BASE (AHB1PERIPH_BASE + 0x1C00UL)
#define CRC_BASE (AHB1PERIPH_BASE + 0x3000UL)
#define RCC_BASE (AHB1PERIPH_BASE + 0x3800UL)
#define RCC_AHB1ENR ((uint32_t *)(RCC_BASE + 0x30UL))
#define GPIOA_MODER ((uint32_t *)(GPIOA_BASE + 0x00ul))
#define GPIOA_ODR ((uint32_t *)(GPIOA_BASE + 0x14ul))
#define STACK_SIZE 512*4 // bytes
#define NTHREADS 2
struct stackframe_t
{
uint32_t r0; // 0
uint32_t r1; // 1
uint32_t r2; // 2
uint32_t r3; // 3
uint32_t r12; // 4
uint32_t r14; // LR, 5
uint32_t* retaddr; // 6 return address
uint32_t xpsr; // program status word
};
// this is for later use
struct thread_t
{
uint32_t * sp;
};
// Type for the threadtable
struct threadtbl_t
{
struct thread_t tbl[NTHREADS];
uint32_t running; // holds the index of the currently running process
uint32_t lock; // for future use
};
int main();
void ledon();
void ledoff();
extern void SVC_Handler();
extern void SysTick_Handler();
void delay(volatile uint32_t);
void _start();