diff --git a/software/firmware/project_oracle_test_prj/.vs/project_oracle_test_prj/v14/.atsuo b/software/firmware/project_oracle_test_prj/.vs/project_oracle_test_prj/v14/.atsuo index 49c6e5f..99c8c90 100644 Binary files a/software/firmware/project_oracle_test_prj/.vs/project_oracle_test_prj/v14/.atsuo and b/software/firmware/project_oracle_test_prj/.vs/project_oracle_test_prj/v14/.atsuo differ diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/atmel_start.c b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/atmel_start.c deleted file mode 100644 index 9d0900d..0000000 --- a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/atmel_start.c +++ /dev/null @@ -1,9 +0,0 @@ -#include - -/** - * Initializes MCU, drivers and middleware in the project - **/ -void atmel_start_init(void) -{ - system_init(); -} diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/atmel_start.h b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/atmel_start.h deleted file mode 100644 index a035c6c..0000000 --- a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/atmel_start.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef ATMEL_START_H_INCLUDED -#define ATMEL_START_H_INCLUDED - -#ifdef __cplusplus -extern "C" { -#endif - -#include "driver_init.h" - -/** - * Initializes MCU, drivers and middleware in the project - **/ -void atmel_start_init(void); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/atmel_start_pins.h b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/atmel_start_pins.h deleted file mode 100644 index 1344f6c..0000000 --- a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/atmel_start_pins.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - * Code generated from Atmel Start. - * - * This file will be overwritten when reconfiguring your Atmel Start project. - * Please copy examples or other code you want to keep to a separate file - * to avoid losing it when reconfiguring. - */ -#ifndef ATMEL_START_PINS_H_INCLUDED -#define ATMEL_START_PINS_H_INCLUDED - - -#endif // ATMEL_START_PINS_H_INCLUDED diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/devices/test.h b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/devices/display/p_ssd1963.c similarity index 100% rename from software/firmware/project_oracle_test_prj/project_oracle_test_prj/devices/test.h rename to software/firmware/project_oracle_test_prj/project_oracle_test_prj/devices/display/p_ssd1963.c diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/devices/display/p_ssd1963.h b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/devices/display/p_ssd1963.h new file mode 100644 index 0000000..e69de29 diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/driver_init.c b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/driver_init.c deleted file mode 100644 index 2ee900b..0000000 --- a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/driver_init.c +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Code generated from Atmel Start. - * - * This file will be overwritten when reconfiguring your Atmel Start project. - * Please copy examples or other code you want to keep to a separate file - * to avoid losing it when reconfiguring. - */ - -#include "driver_init.h" -#include -#include -#include - -/*! The buffer size for USART */ -#define USART_0_BUFFER_SIZE 16 - -struct usart_async_descriptor USART_0; -struct timer_descriptor TIMER_0; - -static uint8_t USART_0_buffer[USART_0_BUFFER_SIZE]; - -struct i2c_m_sync_desc I2C_0; - -void EXTERNAL_IRQ_0_init(void) -{ - hri_gclk_write_PCHCTRL_reg(GCLK, EIC_GCLK_ID, CONF_GCLK_EIC_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos)); - hri_mclk_set_APBAMASK_EIC_bit(MCLK); - - ext_irq_init(); -} - -/** - * \brief USART Clock initialization function - * - * Enables register interface and peripheral clock - */ -void USART_0_CLOCK_init() -{ - - hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM2_GCLK_ID_CORE, CONF_GCLK_SERCOM2_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos)); - hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM2_GCLK_ID_SLOW, CONF_GCLK_SERCOM2_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos)); - - hri_mclk_set_APBBMASK_SERCOM2_bit(MCLK); -} - -/** - * \brief USART pinmux initialization function - * - * Set each required pin to USART functionality - */ -void USART_0_PORT_init() -{ - - gpio_set_pin_function(PB25, PINMUX_PB25D_SERCOM2_PAD0); - - gpio_set_pin_function(PB24, PINMUX_PB24D_SERCOM2_PAD1); -} - -/** - * \brief USART initialization function - * - * Enables USART peripheral, clocks and initializes USART driver - */ -void USART_0_init(void) -{ - USART_0_CLOCK_init(); - usart_async_init(&USART_0, SERCOM2, USART_0_buffer, USART_0_BUFFER_SIZE, (void *)NULL); - USART_0_PORT_init(); -} - -void I2C_0_PORT_init(void) -{ - - gpio_set_pin_pull_mode(PA22, - // Pull configuration - // pad_pull_config - // Off - // Pull-up - // Pull-down - GPIO_PULL_OFF); - - gpio_set_pin_function(PA22, PINMUX_PA22C_SERCOM3_PAD0); - - gpio_set_pin_pull_mode(PA23, - // Pull configuration - // pad_pull_config - // Off - // Pull-up - // Pull-down - GPIO_PULL_OFF); - - gpio_set_pin_function(PA23, PINMUX_PA23C_SERCOM3_PAD1); -} - -void I2C_0_CLOCK_init(void) -{ - hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_CORE, CONF_GCLK_SERCOM3_CORE_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos)); - hri_gclk_write_PCHCTRL_reg(GCLK, SERCOM3_GCLK_ID_SLOW, CONF_GCLK_SERCOM3_SLOW_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos)); - - hri_mclk_set_APBBMASK_SERCOM3_bit(MCLK); -} - -void I2C_0_init(void) -{ - I2C_0_CLOCK_init(); - i2c_m_sync_init(&I2C_0, SERCOM3); - I2C_0_PORT_init(); -} - -/** - * \brief Timer initialization function - * - * Enables Timer peripheral, clocks and initializes Timer driver - */ -static void TIMER_0_init(void) -{ - hri_mclk_set_APBAMASK_TC0_bit(MCLK); - hri_gclk_write_PCHCTRL_reg(GCLK, TC0_GCLK_ID, CONF_GCLK_TC0_SRC | (1 << GCLK_PCHCTRL_CHEN_Pos)); - - timer_init(&TIMER_0, TC0, _tc_get_timer()); -} - -void system_init(void) -{ - init_mcu(); - - EXTERNAL_IRQ_0_init(); - - USART_0_init(); - - I2C_0_init(); - - TIMER_0_init(); -} diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/driver_init.h b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/driver_init.h deleted file mode 100644 index b82abbb..0000000 --- a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/driver_init.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Code generated from Atmel Start. - * - * This file will be overwritten when reconfiguring your Atmel Start project. - * Please copy examples or other code you want to keep to a separate file - * to avoid losing it when reconfiguring. - */ -#ifndef DRIVER_INIT_INCLUDED -#define DRIVER_INIT_INCLUDED - -#include "atmel_start_pins.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include -#include -#include - -extern struct usart_async_descriptor USART_0; - -extern struct i2c_m_sync_desc I2C_0; -extern struct timer_descriptor TIMER_0; - -void USART_0_PORT_init(void); -void USART_0_CLOCK_init(void); -void USART_0_init(void); - -void I2C_0_CLOCK_init(void); -void I2C_0_init(void); -void I2C_0_PORT_init(void); - -/** - * \brief Perform system initialization, initialize pins and clocks for - * peripherals - */ -void system_init(void); - -#ifdef __cplusplus -} -#endif -#endif // DRIVER_INIT_INCLUDED diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_gpio.c b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_gpio.c index e69de29..5ebb120 100644 --- a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_gpio.c +++ b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_gpio.c @@ -0,0 +1,8 @@ + + +/** + * Example of using EXTERNAL_IRQ_0 + */ +void EXTERNAL_IRQ_0_example(void) +{ +} diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_i2c.c b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_i2c.c index e69de29..73f5d52 100644 --- a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_i2c.c +++ b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_i2c.c @@ -0,0 +1,13 @@ + + + +void I2C_0_example(void) +{ + struct io_descriptor *I2C_0_io; + + i2c_m_sync_get_io_descriptor(&I2C_0, &I2C_0_io); + i2c_m_sync_enable(&I2C_0); + i2c_m_sync_set_slaveaddr(&I2C_0, 0x12, I2C_M_SEVEN); + io_write(I2C_0_io, (uint8_t *)"Hello World!", 12); +} + diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_tcc.c b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_tcc.c index e69de29..047479c 100644 --- a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_tcc.c +++ b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_tcc.c @@ -0,0 +1,28 @@ + + +static struct timer_task TIMER_0_task1, TIMER_0_task2; + +/** + * Example of using TIMER_0. + */ +static void TIMER_0_task1_cb(const struct timer_task *const timer_task) +{ +} + +static void TIMER_0_task2_cb(const struct timer_task *const timer_task) +{ +} + +void TIMER_0_example(void) +{ + TIMER_0_task1.interval = 100; + TIMER_0_task1.cb = TIMER_0_task1_cb; + TIMER_0_task1.mode = TIMER_TASK_REPEAT; + TIMER_0_task2.interval = 200; + TIMER_0_task2.cb = TIMER_0_task2_cb; + TIMER_0_task2.mode = TIMER_TASK_REPEAT; + + timer_add_task(&TIMER_0, &TIMER_0_task1); + timer_add_task(&TIMER_0, &TIMER_0_task2); + timer_start(&TIMER_0); +} diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_usart.c b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_usart.c index 4c9bcd8..bacb09d 100644 --- a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_usart.c +++ b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/drivers/p_usart.c @@ -1,6 +1,9 @@ #include "p_usart.h" static usart_async_descriptor debug_inst; + +static uint8_t example_USART_0[12] = "Hello World!"; + static uint8_t debug_buffer[DEBUG_MAX_BUFFER_SIZE] void p_usart_init(void) { @@ -15,4 +18,32 @@ void p_write(struct usart_async_descriptor* const inst, const uint8_t* data, uin void p_debug(const char* str, ...) { -} \ No newline at end of file +} + + + +/** + * Example of using USART_0 to write "Hello World" using the IO abstraction. + * + * Since the driver is asynchronous we need to use statically allocated memory for string + * because driver initiates transfer and then returns before the transmission is completed. + * + * Once transfer has been completed the tx_cb function will be called. + */ +static void tx_cb_USART_0(const struct usart_async_descriptor *const io_descr) +{ + /* Transfer completed */ +} + +void USART_0_example(void) +{ + struct io_descriptor *io; + + usart_async_register_callback(&USART_0, USART_ASYNC_TXC_CB, tx_cb_USART_0); + /*usart_async_register_callback(&USART_0, USART_ASYNC_RXC_CB, rx_cb); + usart_async_register_callback(&USART_0, USART_ASYNC_ERROR_CB, err_cb);*/ + usart_async_get_io_descriptor(&USART_0, &io); + usart_async_enable(&USART_0); + + io_write(io, example_USART_0, 12); +} diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/examples/driver_examples.c b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/examples/driver_examples.c deleted file mode 100644 index 4218cbe..0000000 --- a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/examples/driver_examples.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Code generated from Atmel Start. - * - * This file will be overwritten when reconfiguring your Atmel Start project. - * Please copy examples or other code you want to keep to a separate file - * to avoid losing it when reconfiguring. - */ - -#include "driver_examples.h" -#include "driver_init.h" -#include "utils.h" - -/** - * Example of using EXTERNAL_IRQ_0 - */ -void EXTERNAL_IRQ_0_example(void) -{ -} - -/** - * Example of using USART_0 to write "Hello World" using the IO abstraction. - * - * Since the driver is asynchronous we need to use statically allocated memory for string - * because driver initiates transfer and then returns before the transmission is completed. - * - * Once transfer has been completed the tx_cb function will be called. - */ - -static uint8_t example_USART_0[12] = "Hello World!"; - -static void tx_cb_USART_0(const struct usart_async_descriptor *const io_descr) -{ - /* Transfer completed */ -} - -void USART_0_example(void) -{ - struct io_descriptor *io; - - usart_async_register_callback(&USART_0, USART_ASYNC_TXC_CB, tx_cb_USART_0); - /*usart_async_register_callback(&USART_0, USART_ASYNC_RXC_CB, rx_cb); - usart_async_register_callback(&USART_0, USART_ASYNC_ERROR_CB, err_cb);*/ - usart_async_get_io_descriptor(&USART_0, &io); - usart_async_enable(&USART_0); - - io_write(io, example_USART_0, 12); -} - -void I2C_0_example(void) -{ - struct io_descriptor *I2C_0_io; - - i2c_m_sync_get_io_descriptor(&I2C_0, &I2C_0_io); - i2c_m_sync_enable(&I2C_0); - i2c_m_sync_set_slaveaddr(&I2C_0, 0x12, I2C_M_SEVEN); - io_write(I2C_0_io, (uint8_t *)"Hello World!", 12); -} - -static struct timer_task TIMER_0_task1, TIMER_0_task2; - -/** - * Example of using TIMER_0. - */ -static void TIMER_0_task1_cb(const struct timer_task *const timer_task) -{ -} - -static void TIMER_0_task2_cb(const struct timer_task *const timer_task) -{ -} - -void TIMER_0_example(void) -{ - TIMER_0_task1.interval = 100; - TIMER_0_task1.cb = TIMER_0_task1_cb; - TIMER_0_task1.mode = TIMER_TASK_REPEAT; - TIMER_0_task2.interval = 200; - TIMER_0_task2.cb = TIMER_0_task2_cb; - TIMER_0_task2.mode = TIMER_TASK_REPEAT; - - timer_add_task(&TIMER_0, &TIMER_0_task1); - timer_add_task(&TIMER_0, &TIMER_0_task2); - timer_start(&TIMER_0); -} diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/examples/driver_examples.h b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/examples/driver_examples.h deleted file mode 100644 index bebd724..0000000 --- a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/examples/driver_examples.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Code generated from Atmel Start. - * - * This file will be overwritten when reconfiguring your Atmel Start project. - * Please copy examples or other code you want to keep to a separate file - * to avoid losing it when reconfiguring. - */ -#ifndef DRIVER_EXAMPLES_H_INCLUDED -#define DRIVER_EXAMPLES_H_INCLUDED - -#ifdef __cplusplus -extern "C" { -#endif - -void EXTERNAL_IRQ_0_example(void); - -void USART_0_example(void); - -void I2C_0_example(void); - -void TIMER_0_example(void); - -#ifdef __cplusplus -} -#endif -#endif // DRIVER_EXAMPLES_H_INCLUDED diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/oracle.c b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/oracle.c index 4310f82..8525bc9 100644 --- a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/oracle.c +++ b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/oracle.c @@ -8,5 +8,15 @@ void oracle_init(void) { + // init mcu + // uart init + + // i2c init + + // gpio init + + // time init + + // devices init } \ No newline at end of file diff --git a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/project_oracle_test_prj.cproj b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/project_oracle_test_prj.cproj index af86218..0edd5df 100644 --- a/software/firmware/project_oracle_test_prj/project_oracle_test_prj/project_oracle_test_prj.cproj +++ b/software/firmware/project_oracle_test_prj/project_oracle_test_prj/project_oracle_test_prj.cproj @@ -30,15 +30,15 @@ - - - - - - - - - + + + + + + + + + .atmelstart\atmel_start_config.atstart .atmelstart\AtmelStart.gpdsc @@ -418,15 +418,6 @@ - - compile - - - compile - - - compile - compile @@ -469,6 +460,12 @@ compile + + compile + + + compile + compile @@ -499,15 +496,6 @@ compile - - compile - - - compile - - - compile - compile