diff options
-rw-r--r-- | Smol Watch Project/My Project/.atmelstart/atmel_start_config.atstart | 12 | ||||
-rw-r--r-- | Smol Watch Project/My Project/Config/hpl_osc32kctrl_config.h | 4 | ||||
-rw-r--r-- | Smol Watch Project/My Project/My Project.cproj | 9 | ||||
-rw-r--r-- | Smol Watch Project/My Project/driver_init.c | 8 | ||||
-rw-r--r-- | Smol Watch Project/My Project/driver_init.h | 2 | ||||
-rw-r--r-- | Smol Watch Project/My Project/main.c | 88 | ||||
-rw-r--r-- | Smol Watch Project/My Project/mars_clock.c | 17 | ||||
-rw-r--r-- | Smol Watch Project/My Project/mars_clock.h | 17 | ||||
-rw-r--r-- | Smol Watch Project/My Project/watch-library/watch.c | 8 | ||||
-rw-r--r-- | Smol Watch Project/My Project/watch-library/watch.h | 4 |
10 files changed, 116 insertions, 53 deletions
diff --git a/Smol Watch Project/My Project/.atmelstart/atmel_start_config.atstart b/Smol Watch Project/My Project/.atmelstart/atmel_start_config.atstart index 0e0d365d..1a511ffe 100644 --- a/Smol Watch Project/My Project/.atmelstart/atmel_start_config.atstart +++ b/Smol Watch Project/My Project/.atmelstart/atmel_start_config.atstart @@ -524,10 +524,10 @@ drivers: functionality: System api: HAL:HPL:GCLK configuration: - $input: 400000 - $input_id: External Crystal Oscillator 0.4-32MHz (XOSC) - RESERVED_InputFreq: 400000 - RESERVED_InputFreq_id: External Crystal Oscillator 0.4-32MHz (XOSC) + $input: 32768 + $input_id: 32kHz External Crystal Oscillator (XOSC32K) + RESERVED_InputFreq: 32768 + RESERVED_InputFreq_id: 32kHz External Crystal Oscillator (XOSC32K) _$freq_output_Generic clock generator 0: 4000000 _$freq_output_Generic clock generator 1: 400000 _$freq_output_Generic clock generator 2: 400000 @@ -639,8 +639,8 @@ drivers: xosc32k_arch_en32k: true xosc32k_arch_enable: true xosc32k_arch_ondemand: true - xosc32k_arch_runstdby: false - xosc32k_arch_startup: 62592us + xosc32k_arch_runstdby: true + xosc32k_arch_startup: 2000092us xosc32k_arch_swben: false xosc32k_arch_xtalen: true optional_signals: [] diff --git a/Smol Watch Project/My Project/Config/hpl_osc32kctrl_config.h b/Smol Watch Project/My Project/Config/hpl_osc32kctrl_config.h index 55e297ae..40206331 100644 --- a/Smol Watch Project/My Project/Config/hpl_osc32kctrl_config.h +++ b/Smol Watch Project/My Project/Config/hpl_osc32kctrl_config.h @@ -81,7 +81,7 @@ // <0x6=>8000092us // <id> xosc32k_arch_startup #ifndef CONF_XOSC32K_STARTUP -#define CONF_XOSC32K_STARTUP 0x0 +#define CONF_XOSC32K_STARTUP 0x4 #endif // <q> On Demand Control @@ -95,7 +95,7 @@ // <i> Indicates whether Run in Standby is enabled or not // <id> xosc32k_arch_runstdby #ifndef CONF_XOSC32K_RUNSTDBY -#define CONF_XOSC32K_RUNSTDBY 0 +#define CONF_XOSC32K_RUNSTDBY 1 #endif // <q> 1kHz Output Enable diff --git a/Smol Watch Project/My Project/My Project.cproj b/Smol Watch Project/My Project/My Project.cproj index bffa9708..7149baaa 100644 --- a/Smol Watch Project/My Project/My Project.cproj +++ b/Smol Watch Project/My Project/My Project.cproj @@ -201,7 +201,7 @@ <AcmeProjectActionInfo Action="File" Source="config/hpl_eic_config.h" IsConfig="true" Hash="U9WSM5Hq8sGLa8ysciEfCg" />
<AcmeProjectActionInfo Action="File" Source="config/hpl_gclk_config.h" IsConfig="true" Hash="VW757Ebgq5TyYTRcpY8M7w" />
<AcmeProjectActionInfo Action="File" Source="config/hpl_mclk_config.h" IsConfig="true" Hash="CLrsNUvv74/qlHdF8aFndg" />
- <AcmeProjectActionInfo Action="File" Source="config/hpl_osc32kctrl_config.h" IsConfig="true" Hash="ylDzEsTDHvv+guzMsTa+sg" />
+ <AcmeProjectActionInfo Action="File" Source="config/hpl_osc32kctrl_config.h" IsConfig="true" Hash="b7mSwnFOSDceVn9b3TT9kA" />
<AcmeProjectActionInfo Action="File" Source="config/hpl_oscctrl_config.h" IsConfig="true" Hash="Vc5u27WzT+UPF5aLAxl2lQ" />
<AcmeProjectActionInfo Action="File" Source="config/hpl_port_config.h" IsConfig="true" Hash="rMTNR+5FXtu+wfT1NbfRRA" />
<AcmeProjectActionInfo Action="File" Source="config/hpl_rtc_config.h" IsConfig="true" Hash="oTcobT9ydLDOqfpwUidHvg" />
@@ -410,6 +410,7 @@ </ListValues>
</armgcc.linker.libraries.LibrarySearchPaths>
<armgcc.linker.optimization.GarbageCollectUnusedSections>True</armgcc.linker.optimization.GarbageCollectUnusedSections>
+ <armgcc.linker.memorysettings.ExternalRAM />
<armgcc.linker.miscellaneous.LinkerFlags>-Tsaml22j18a_flash.ld</armgcc.linker.miscellaneous.LinkerFlags>
<armgcc.assembler.general.IncludePaths>
<ListValues>
@@ -952,6 +953,12 @@ <Compile Include="hri\hri_wdt_l22.h">
<SubType>compile</SubType>
</Compile>
+ <Compile Include="mars_clock.c">
+ <SubType>compile</SubType>
+ </Compile>
+ <Compile Include="mars_clock.h">
+ <SubType>compile</SubType>
+ </Compile>
<Compile Include="main.c">
<SubType>compile</SubType>
</Compile>
diff --git a/Smol Watch Project/My Project/driver_init.c b/Smol Watch Project/My Project/driver_init.c index b10ed0e4..c4223ebc 100644 --- a/Smol Watch Project/My Project/driver_init.c +++ b/Smol Watch Project/My Project/driver_init.c @@ -270,7 +270,7 @@ void SEGMENT_LCD_0_init(void) void system_init(void) { init_mcu(); - +/* // GPIO on PA02 // Set pin direction to input @@ -314,10 +314,6 @@ void system_init(void) gpio_set_pin_function(D0, GPIO_PIN_FUNCTION_OFF); - delay_driver_init(); - - -/* ADC_0_init(); EXTERNAL_IRQ_0_init(); @@ -326,6 +322,8 @@ void system_init(void) I2C_0_init(); + delay_driver_init(); + PWM_0_init(); PWM_1_init(); diff --git a/Smol Watch Project/My Project/driver_init.h b/Smol Watch Project/My Project/driver_init.h index 4761a929..8ed98cb6 100644 --- a/Smol Watch Project/My Project/driver_init.h +++ b/Smol Watch Project/My Project/driver_init.h @@ -69,6 +69,8 @@ void PWM_1_PORT_init(void); void PWM_1_CLOCK_init(void); void PWM_1_init(void); +void EXTERNAL_IRQ_0_init(void); + void SEGMENT_LCD_0_init(void); /** diff --git a/Smol Watch Project/My Project/main.c b/Smol Watch Project/My Project/main.c index 8289731b..f19d7a29 100644 --- a/Smol Watch Project/My Project/main.c +++ b/Smol Watch Project/My Project/main.c @@ -1,56 +1,66 @@ #include <atmel_start.h> +#include <hpl_sleep.h> #include "watch-library/watch.h" +#include "mars_clock.h" + +Watch watch; +bool local = true; + +void calendar_callback(struct calendar_descriptor *const calendar) { + struct calendar_date_time date_time; + calendar_get_date_time(&CALENDAR_0, &date_time); + + update_display(&watch, date_time, true); +/* + if (date_time.time.min % 2 == 0) { + watch_set_led_color(50, 0); + } else { + watch_set_led_color(0, 50); + } +*/ +} + +static void mode_callback() { +// local = !local; + struct calendar_date_time date_time; + calendar_get_date_time(&CALENDAR_0, &date_time); + update_display(&watch, date_time, local); +} int main(void) { atmel_start_init(); - Watch watch; - struct calendar_date_time date_time; - date_time.date.year = 2021; - date_time.date.month = 4; - date_time.date.day = 25; - date_time.time.hour = 4; - date_time.time.min = 0; - date_time.time.sec = 0; - watch_init(&watch); - watch_enable_led(&watch); +// watch_enable_led(&watch); + + watch_enable_display(&watch); + watch_display_pixel(&watch, 1, 16); + + watch_enable_interrupts(&watch); + watch_register_interrupt_callback(&watch, BTN_MODE, &mode_callback); watch_enable_date_time(&watch); + struct calendar_date_time date_time; + date_time.date.year = 2021; + date_time.date.month = 4; + date_time.date.day = 30; + date_time.time.hour = 9; + date_time.time.min = 40; + date_time.time.sec = 0; watch_set_date_time(date_time); + struct calendar_alarm alarm; + alarm.cal_alarm.mode = REPEAT; + alarm.cal_alarm.datetime = date_time; + alarm.cal_alarm.datetime.time.sec = 0; + alarm.cal_alarm.option = CALENDAR_ALARM_MATCH_SEC; + alarm.callback = calendar_callback; + update_display(&watch, date_time, local); + calendar_set_alarm(&CALENDAR_0, &alarm, &calendar_callback); - watch_enable_digital_output(A0); - gpio_set_pin_level(A0, true); - - watch_enable_display(&watch); -/* - watch_enable_i2c(&watch); - uint8_t chipID = 0; - uint8_t ChipIdRegister = 0xD0; - watch_i2c_send(0x77, &ChipIdRegister, 1); - watch_i2c_receive(0x77, &chipID, 1); - if (chipID == 0x60) { - watch_set_led_green(); - } -*/ - uint8_t last = date_time.time.sec; - while (1) { - watch_get_date_time(&date_time); - if (date_time.time.sec != last) { - last = date_time.time.sec; - if (last % 2 == 0) { - watch_set_led_color(50, 0); - watch_display_string(&watch, "0123456789", 0); - } else { - watch_set_led_color(0, 50); - watch_display_string(&watch, "01", 0); - watch_display_string(&watch, "23", 2); - watch_display_string(&watch, "456789", 4); - } - } + //sleep(4); } return 0; diff --git a/Smol Watch Project/My Project/mars_clock.c b/Smol Watch Project/My Project/mars_clock.c new file mode 100644 index 00000000..1bafa023 --- /dev/null +++ b/Smol Watch Project/My Project/mars_clock.c @@ -0,0 +1,17 @@ +/*
+ * mars_clock.c
+ *
+ * Created: 4/29/2021 11:36:26 PM
+ * Author: joeycastillo
+ */
+#include <stdio.h>
+#include <math.h>
+#include "mars_clock.h"
+
+// note: mars time not working, committing just the earth clock.
+
+void update_display(Watch *watch, struct calendar_date_time date_time, bool local) { + char buf[6]; + sprintf(&buf[0], "TE %02d%02d", date_time.time.hour, date_time.time.min); + watch_display_string(watch, buf, 0); +} diff --git a/Smol Watch Project/My Project/mars_clock.h b/Smol Watch Project/My Project/mars_clock.h new file mode 100644 index 00000000..71b45f33 --- /dev/null +++ b/Smol Watch Project/My Project/mars_clock.h @@ -0,0 +1,17 @@ +/*
+ * mars_clock.h
+ *
+ * Created: 4/29/2021 11:35:39 PM
+ * Author: joeycastillo
+ */
+
+
+#ifndef MARS_CLOCK_H_
+#define MARS_CLOCK_H_
+#include "hpl_calendar.h"
+#include "watch-library/watch.h"
+
+void update_display(Watch *watch, struct calendar_date_time date_time, bool local);
+
+
+#endif /* MARS_CLOCK_H_ */
\ No newline at end of file diff --git a/Smol Watch Project/My Project/watch-library/watch.c b/Smol Watch Project/My Project/watch-library/watch.c index ad4e7632..73d67c35 100644 --- a/Smol Watch Project/My Project/watch-library/watch.c +++ b/Smol Watch Project/My Project/watch-library/watch.c @@ -173,6 +173,14 @@ void watch_display_string(Watch *watch, char *string, uint8_t position) { } } +void watch_enable_interrupts(Watch *watch) { + EXTERNAL_IRQ_0_init(); +} +
+void watch_register_interrupt_callback(Watch *watch, const uint32_t pin, ext_irq_cb_t callback) { + ext_irq_register(pin, callback); +} +
void watch_enable_led(Watch *watch) {
if (watch->led_enabled) return;
diff --git a/Smol Watch Project/My Project/watch-library/watch.h b/Smol Watch Project/My Project/watch-library/watch.h index cab19bec..876c240a 100644 --- a/Smol Watch Project/My Project/watch-library/watch.h +++ b/Smol Watch Project/My Project/watch-library/watch.h @@ -10,6 +10,7 @@ #define WATCH_H_
#include <stdint.h>
#include "hpl_calendar.h"
+#include "hal_ext_irq.h"
typedef struct Watch {
bool display_enabled;
@@ -43,6 +44,9 @@ void watch_get_date_time(struct calendar_date_time *date_time); void watch_enable_analog(Watch *watch, const uint8_t pin); +void watch_enable_interrupts(Watch *watch); +void watch_register_interrupt_callback(Watch *watch, const uint32_t pin, ext_irq_cb_t callback); + void watch_enable_digital_input(const uint8_t pin); void watch_enable_digital_output(const uint8_t pin); |