gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
system.h
1/*
2 * MIT License
3 *
4 * Copyright (c) 2020 Joey Castillo
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25#include <stdint.h>
26#include <stdbool.h>
27#include <stddef.h>
28#include "sam.h"
29
30#pragma once
31
32#if __EMSCRIPTEN__
33
34typedef int tc_instance_details_t;
35typedef int tcc_instance_details_t;
37
38#else
39
40typedef struct {
41 Tc* tc;
42 uint32_t clock_enable_mask;
43 uint8_t gclk_id;
45
46typedef struct {
47 Tcc* tcc;
48 uint32_t clock_enable_mask;
49 uint8_t gclk_id;
51
52typedef struct {
53 Sercom* sercom;
54 uint32_t clock_enable_mask;
55 uint8_t gclk_id;
56 uint8_t interrupt_line;
58
59#endif
60
61extern const tc_instance_details_t TC_Peripherals[];
62extern const uint8_t Num_TC_Instances;
63extern const uint8_t TC_First_Index;
64
65extern const tcc_instance_details_t TCC_Peripherals[];
66extern const uint8_t Num_TCC_Instances;
67
68extern const sercom_instance_details_t SERCOM_Peripherals[];
69extern const uint8_t Num_SERCOM_Instances;
70
72
93void sys_init(void);
94
98uint32_t get_cpu_frequency(void);
99
115bool set_cpu_frequency(uint32_t freq);
116
126
133
void _enter_standby_mode(void)
Enters the low-power STANDBY mode. Does not return until an interrupt fires.
bool set_cpu_frequency(uint32_t freq)
Sets the CPU frequency.
uint32_t get_cpu_frequency(void)
Gets the CPU frequency.
void sys_init(void)
Initializes the system clocks and performs any required system-wide setup.
void _enable_48mhz_gclk1(void)
Enables the 48 MHz clock on GCLK1 for USB operation.
Definition system.h:52
Definition system.h:40
Definition system.h:46