diff options
author | Joey Castillo <jose.castillo@gmail.com> | 2021-08-01 18:40:03 -0400 |
---|---|---|
committer | Joey Castillo <jose.castillo@gmail.com> | 2021-08-01 18:40:42 -0400 |
commit | 7e330befffdc2783207b83f12f30f328f5f3318d (patch) | |
tree | 92bc6d757d4dc0409d95b40efcd40ccd7372e049 /Sensor Watch Starter Project/main.c | |
parent | a547d78c1edfaeb9075934c87753b3352a4ece46 (diff) | |
download | Sensor-Watch-7e330befffdc2783207b83f12f30f328f5f3318d.tar.gz Sensor-Watch-7e330befffdc2783207b83f12f30f328f5f3318d.tar.bz2 Sensor-Watch-7e330befffdc2783207b83f12f30f328f5f3318d.zip |
move user application code to app folder
Diffstat (limited to 'Sensor Watch Starter Project/main.c')
-rwxr-xr-x | Sensor Watch Starter Project/main.c | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/Sensor Watch Starter Project/main.c b/Sensor Watch Starter Project/main.c index 4569c4be..052bbfa0 100755 --- a/Sensor Watch Starter Project/main.c +++ b/Sensor Watch Starter Project/main.c @@ -39,13 +39,12 @@ #include "hal_gpio.h" #include "atmel_start_pins.h" #include "watch.h" +#include "app.h" //----------------------------------------------------------------------------- HAL_GPIO_PIN(UART_TX, B, 0) HAL_GPIO_PIN(UART_RX, B, 2) -Watch watch; - //----------------------------------------------------------------------------- static void uart_init(uint32_t baud) { uint64_t br = (uint64_t)65536 * (CONF_CPU_FREQUENCY - 16 * baud) / CONF_CPU_FREQUENCY; @@ -73,52 +72,35 @@ static void uart_init(uint32_t baud) { } //----------------------------------------------------------------------------- -static void uart_putc(char c) { +void uart_putc(char c) { while (!(SERCOM3->USART.INTFLAG.reg & SERCOM_USART_INTFLAG_DRE)); SERCOM3->USART.DATA.reg = c; } //----------------------------------------------------------------------------- -static void uart_puts(char *s) { +void uart_puts(char *s) { while (*s) uart_putc(*s++); } //----------------------------------------------------------------------------- static void sys_init(void) { + uart_puts("init_mcu\n"); init_mcu(); - watch_init(&watch); - watch_enable_display(&watch); - watch_enable_led(&watch); - watch_enable_date_time(&watch); - watch_enable_analog(&watch, A0); - watch_enable_buttons(&watch); - watch_enable_i2c(&watch); + uart_puts("watch_init\n"); + watch_init(); + uart_puts("app_init\n"); + app_init(); } //----------------------------------------------------------------------------- int main(void) { - sys_init(); uart_init(115200); + sys_init(); - char buf[20] = {0}; - - uart_puts("\n\nI2C Driver Test\n"); - uint8_t reset_cmd[] = {0xE0, 0xB6}; - watch_i2c_send(0x77, reset_cmd, 2); - uart_puts("Reset BMP280\n"); - uint8_t chip_id_cmd = 0xD0; - uint8_t chip_id = 0; - watch_i2c_send(0x77, &chip_id_cmd, 1); - uart_puts("Chip ID... "); - watch_i2c_receive(0x77, &chip_id, 1); - uart_puts("received!\n"); - sprintf(buf, "Chip ID is %#02x", chip_id); - uart_puts(buf); - uart_puts("\nDone\n"); - - uint16_t red = 0; - uint16_t green = 0; while (1) { + app_loop(); + app_prepare_for_sleep(); + sleep(4); } return 0; |