summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoey Castillo <jose.castillo@gmail.com>2021-07-30 13:49:09 -0400
committerJoey Castillo <jose.castillo@gmail.com>2021-07-30 13:49:09 -0400
commit6d2e5cd69754b45ec0aa7b4559709a461e376578 (patch)
tree912e15682289d696b94ccc4d938a3888b40cc92c
parente68086a087e0a7756fc377b9bd894c2b8d929e68 (diff)
downloadSensor-Watch-6d2e5cd69754b45ec0aa7b4559709a461e376578.tar.gz
Sensor-Watch-6d2e5cd69754b45ec0aa7b4559709a461e376578.tar.bz2
Sensor-Watch-6d2e5cd69754b45ec0aa7b4559709a461e376578.zip
use atmel studio's configuration and init
-rw-r--r--Sensor Watch Starter Project/hw/atmel_start_pins.h67
-rw-r--r--Sensor Watch Starter Project/hw/driver_init.c0
-rw-r--r--Sensor Watch Starter Project/hw/driver_init.h80
-rwxr-xr-xSensor Watch Starter Project/main.c11
-rwxr-xr-xSensor Watch Starter Project/make/Makefile4
5 files changed, 153 insertions, 9 deletions
diff --git a/Sensor Watch Starter Project/hw/atmel_start_pins.h b/Sensor Watch Starter Project/hw/atmel_start_pins.h
new file mode 100644
index 00000000..36fe6bf4
--- /dev/null
+++ b/Sensor Watch Starter Project/hw/atmel_start_pins.h
@@ -0,0 +1,67 @@
+/*
+ * 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
+
+#include <hal_gpio.h>
+
+// SAML22 has 9 pin functions
+
+#define GPIO_PIN_FUNCTION_A 0
+#define GPIO_PIN_FUNCTION_B 1
+#define GPIO_PIN_FUNCTION_C 2
+#define GPIO_PIN_FUNCTION_D 3
+#define GPIO_PIN_FUNCTION_E 4
+#define GPIO_PIN_FUNCTION_F 5
+#define GPIO_PIN_FUNCTION_G 6
+#define GPIO_PIN_FUNCTION_H 7
+#define GPIO_PIN_FUNCTION_I 8
+
+#define VBUS_DET GPIO(GPIO_PORTA, 2)
+#define SEG1 GPIO(GPIO_PORTA, 4)
+#define SEG2 GPIO(GPIO_PORTA, 5)
+#define SEG3 GPIO(GPIO_PORTA, 6)
+#define SEG4 GPIO(GPIO_PORTA, 7)
+#define SEG5 GPIO(GPIO_PORTA, 8)
+#define SEG6 GPIO(GPIO_PORTA, 9)
+#define SEG7 GPIO(GPIO_PORTA, 10)
+#define SEG8 GPIO(GPIO_PORTA, 11)
+#define SEG14 GPIO(GPIO_PORTA, 12)
+#define SEG15 GPIO(GPIO_PORTA, 13)
+#define SEG16 GPIO(GPIO_PORTA, 14)
+#define SEG17 GPIO(GPIO_PORTA, 15)
+#define SEG18 GPIO(GPIO_PORTA, 16)
+#define SEG19 GPIO(GPIO_PORTA, 17)
+#define SEG20 GPIO(GPIO_PORTA, 18)
+#define SEG21 GPIO(GPIO_PORTA, 19)
+#define RED GPIO(GPIO_PORTA, 20)
+#define GREEN GPIO(GPIO_PORTA, 21)
+#define BTN_LIGHT GPIO(GPIO_PORTA, 22)
+#define BTN_MODE GPIO(GPIO_PORTA, 23)
+#define BUZZER GPIO(GPIO_PORTA, 27)
+#define D1 GPIO(GPIO_PORTB, 0)
+#define A1 GPIO(GPIO_PORTB, 1)
+#define A2 GPIO(GPIO_PORTB, 2)
+#define D0 GPIO(GPIO_PORTB, 3)
+#define A0 GPIO(GPIO_PORTB, 4)
+#define BTN_ALARM GPIO(GPIO_PORTB, 5)
+#define COM0 GPIO(GPIO_PORTB, 6)
+#define COM1 GPIO(GPIO_PORTB, 7)
+#define COM2 GPIO(GPIO_PORTB, 8)
+#define SEG0 GPIO(GPIO_PORTB, 9)
+#define SEG9 GPIO(GPIO_PORTB, 11)
+#define SEG10 GPIO(GPIO_PORTB, 12)
+#define SEG11 GPIO(GPIO_PORTB, 13)
+#define SEG12 GPIO(GPIO_PORTB, 14)
+#define SEG13 GPIO(GPIO_PORTB, 15)
+#define SEG22 GPIO(GPIO_PORTB, 16)
+#define SEG23 GPIO(GPIO_PORTB, 17)
+#define SDA GPIO(GPIO_PORTB, 30)
+#define SCL GPIO(GPIO_PORTB, 31)
+
+#endif // ATMEL_START_PINS_H_INCLUDED
diff --git a/Sensor Watch Starter Project/hw/driver_init.c b/Sensor Watch Starter Project/hw/driver_init.c
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Sensor Watch Starter Project/hw/driver_init.c
diff --git a/Sensor Watch Starter Project/hw/driver_init.h b/Sensor Watch Starter Project/hw/driver_init.h
new file mode 100644
index 00000000..1e53f9a0
--- /dev/null
+++ b/Sensor Watch Starter Project/hw/driver_init.h
@@ -0,0 +1,80 @@
+/*
+ * 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 <hal_atomic.h>
+#include <hal_delay.h>
+#include <hal_gpio.h>
+#include <hal_init.h>
+#include <hal_io.h>
+#include <hal_sleep.h>
+
+#include <hal_adc_sync.h>
+
+#include <hal_ext_irq.h>
+
+#include <hal_calendar.h>
+
+#include <hal_i2c_m_sync.h>
+
+#include <hal_delay.h>
+#include <hpl_tc_base.h>
+#include <hal_pwm.h>
+#include <hpl_tc_base.h>
+
+#include <hal_pwm.h>
+#include <hpl_tcc.h>
+#include <hal_slcd_sync.h>
+
+extern struct adc_sync_descriptor ADC_0;
+
+extern struct calendar_descriptor CALENDAR_0;
+
+extern struct i2c_m_sync_desc I2C_0;
+
+extern struct pwm_descriptor PWM_0;
+
+extern struct pwm_descriptor PWM_1;
+extern struct slcd_sync_descriptor SEGMENT_LCD_0;
+
+void ADC_0_PORT_init(void);
+void ADC_0_CLOCK_init(void);
+void ADC_0_init(void);
+
+void CALENDAR_0_CLOCK_init(void);
+void CALENDAR_0_init(void);
+
+void I2C_0_CLOCK_init(void);
+void I2C_0_init(void);
+void I2C_0_PORT_init(void);
+
+void delay_driver_init(void);
+
+void PWM_0_PORT_init(void);
+void PWM_0_CLOCK_init(void);
+void PWM_0_init(void);
+
+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);
+
+#ifdef __cplusplus
+}
+#endif
+#endif // DRIVER_INIT_INCLUDED
diff --git a/Sensor Watch Starter Project/main.c b/Sensor Watch Starter Project/main.c
index 2ced0560..07f3be90 100755
--- a/Sensor Watch Starter Project/main.c
+++ b/Sensor Watch Starter Project/main.c
@@ -33,6 +33,8 @@
#include <stdbool.h>
#include <string.h>
#include "saml22.h"
+#include "hal_init.h"
+#include "peripheral_clk_config.h"
#include "hal_gpio.h"
//-----------------------------------------------------------------------------
@@ -42,7 +44,7 @@ HAL_GPIO_PIN(UART_RX, B, 2)
//-----------------------------------------------------------------------------
static void uart_init(uint32_t baud) {
- uint64_t br = (uint64_t)65536 * (F_CPU - 16 * baud) / F_CPU;
+ uint64_t br = (uint64_t)65536 * (CONF_CPU_FREQUENCY - 16 * baud) / CONF_CPU_FREQUENCY;
HAL_GPIO_UART_TX_out();
HAL_GPIO_UART_TX_pmuxen(HAL_GPIO_PMUX_C);
@@ -79,12 +81,7 @@ static void uart_puts(char *s) {
//-----------------------------------------------------------------------------
static void sys_init(void) {
- // Switch to 16MHz clock (disable prescaler)
- OSCCTRL->OSC16MCTRL.reg = OSCCTRL_OSC16MCTRL_ENABLE | OSCCTRL_OSC16MCTRL_FSEL_16;
- // Switch to the highest performance level
- PM->INTFLAG.reg = PM_INTFLAG_PLRDY;
- PM->PLCFG.reg = PM_PLCFG_PLSEL_PL2_Val;
- while (!PM->INTFLAG.reg);
+ init_mcu();
}
//-----------------------------------------------------------------------------
diff --git a/Sensor Watch Starter Project/make/Makefile b/Sensor Watch Starter Project/make/Makefile
index b3920644..7a402524 100755
--- a/Sensor Watch Starter Project/make/Makefile
+++ b/Sensor Watch Starter Project/make/Makefile
@@ -55,6 +55,7 @@ INCLUDES += \
-I../hpl/tc/ \
-I../hri/ \
-I../config/ \
+ -I../hw/ \
-I..
SRCS += \
@@ -95,8 +96,7 @@ SRCS += \
DEFINES += \
-D__SAML22J18A__ \
- -DDONT_USE_CMSIS_INIT \
- -DF_CPU=16000000
+ -DDONT_USE_CMSIS_INIT
CFLAGS += $(INCLUDES) $(DEFINES)