This repository has been archived by the owner on Oct 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.c
82 lines (67 loc) · 1.66 KB
/
test.c
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <stdio.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/cm3/systick.h>
#include "led.h"
#include "servo.h"
#include "usart.h"
#define DELAY 4000
#define delay(x) do { for (int i = 0; i < x * 1000; i++) \
__asm__("nop"); \
} while(0)
void init(void) {
rcc_clock_setup_in_hse_8mhz_out_72mhz();
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPAEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPBEN);
rcc_peripheral_enable_clock(&RCC_APB2ENR, RCC_APB2ENR_IOPCEN);
led_init();
usart_init();
// servo_init();
}
int main(void) {
init();
while(1) {
// Servo status LEDs
delay(DELAY);
for (int j=0; j<12; j++)
{
led_out(1<<j);
delay(DELAY);
led_out(0);
}
}
#if 0
// 5V5 SMPS + I2C + GPIO expander
servo_out(0x0000);
delay(DELAY);
// Link
servo_out(0x0040);
delay(DELAY);
// Turn off SMPS and link
servo_out(0x0020);
delay(DELAY);
servo_out(0xff2f);
delay(DELAY);
servo_out(0x0020);
delay(DELAY);
// Status LED
led_set(LED_STATUS_BLUE);
delay(DELAY);
led_clear(LED_STATUS_BLUE);
led_set(LED_STATUS_RED);
delay(DELAY);
led_clear(LED_STATUS_RED);
}
#endif
return 0;
}
// Configure application start address, put in section that'll be placed at
// the start of the non-bootloader firmware. The actual start address is
// libopencm3's reset handler, seeing how that's what copies .data into sram.
extern void *vector_table;
extern __attribute__((naked)) void reset_handler(void);
uint32_t app_start_address[2] __attribute__((section(".lolstartup"))) =
{
(uint32_t)&vector_table,
(uint32_t)&reset_handler,
};