aboutsummaryrefslogtreecommitdiffstats
path: root/app/main.c
diff options
context:
space:
mode:
authorroot <root@no.no.james.local>2017-06-13 21:10:37 +0100
committerroot <root@no.no.james.local>2017-06-13 21:10:37 +0100
commiteaf5d4799cc52e9dd1ebcaeafbf8f670658fea98 (patch)
treebbeb1993818c5fc8cbcf5a001080f246facc8de6 /app/main.c
downloadserial_over_dp-eaf5d4799cc52e9dd1ebcaeafbf8f670658fea98.tar.gz
serial_over_dp-eaf5d4799cc52e9dd1ebcaeafbf8f670658fea98.tar.bz2
serial_over_dp-eaf5d4799cc52e9dd1ebcaeafbf8f670658fea98.zip
inital commit
Diffstat (limited to 'app/main.c')
-rw-r--r--app/main.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/app/main.c b/app/main.c
new file mode 100644
index 0000000..b98bd82
--- /dev/null
+++ b/app/main.c
@@ -0,0 +1,54 @@
+#include "project.h"
+
+
+
+
+
+int main (void)
+{
+ /*set up pll */
+ rcc_clock_setup_in_hse_8mhz_out_72mhz();
+ /*turn on clocks to periferals */
+ rcc_periph_clock_enable (RCC_GPIOA);
+ rcc_periph_clock_enable (RCC_GPIOB);
+ rcc_periph_clock_enable (RCC_GPIOC);
+ rcc_periph_clock_enable (RCC_USART1);
+ rcc_periph_clock_enable (RCC_AFIO);
+ rcc_periph_clock_enable (RCC_I2C1);
+#if 0
+ nvic_set_priority (NVIC_I2C1_EV_IRQ, 0x38);
+ nvic_set_priority (NVIC_I2C1_ER_IRQ, 0x39);
+ nvic_set_priority (NVIC_USART1_IRQ, 0x44);
+ nvic_set_priority (NVIC_SYSTICK_IRQ, 0xff);
+#else
+ nvic_set_priority (NVIC_I2C1_EV_IRQ, 0xff);
+ nvic_set_priority (NVIC_I2C1_ER_IRQ, 0xff);
+ nvic_set_priority (NVIC_SYSTICK_IRQ, 0x80);
+ nvic_set_priority (NVIC_USART1_IRQ, 0x40);
+#endif
+ gpio_set_mode (LED1_BANK, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, LED1_GPIO);
+ gpio_set_mode (LED2_BANK, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_OPENDRAIN, LED2_GPIO);
+ usart_init();
+ ticker_init();
+ printf ("Morning chaps!\r\n");
+#ifdef USB
+ usb_init();
+#endif
+#ifdef I2C_BIT_BANG
+ i2c_bb_init();
+#else
+ i2c_hw_init();
+#endif
+
+ for (;;) {
+#ifdef USB
+ usbd_poll (usbd_dev);
+#endif
+#ifdef I2C_BIT_BANG
+ i2c_bb_poll();
+#endif
+ }
+
+ return 0;
+}
+