summaryrefslogtreecommitdiffstats
path: root/Sensor Watch Starter Project/main.c
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 /Sensor Watch Starter Project/main.c
parente68086a087e0a7756fc377b9bd894c2b8d929e68 (diff)
downloadSensor-Watch-6d2e5cd69754b45ec0aa7b4559709a461e376578.tar.gz
Sensor-Watch-6d2e5cd69754b45ec0aa7b4559709a461e376578.tar.bz2
Sensor-Watch-6d2e5cd69754b45ec0aa7b4559709a461e376578.zip
use atmel studio's configuration and init
Diffstat (limited to 'Sensor Watch Starter Project/main.c')
-rwxr-xr-xSensor Watch Starter Project/main.c11
1 files changed, 4 insertions, 7 deletions
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();
}
//-----------------------------------------------------------------------------