gossamer 0.0.1
a very lightweight app framework for SAMD and SAML chips
Loading...
Searching...
No Matches
spi.h
1
2/*
3 Cribbed from the Castor & Pollux Gemini firmware:
4 https://github.com/wntrblm/Castor_and_Pollux/
5 Copyright (c) 2021 Alethea Katherine Flowers.
6 Published under the standard MIT License.
7 Full text available at: https://opensource.org/licenses/MIT
8*/
9
10#pragma once
11
12#include <stdint.h>
13#include <stdbool.h>
14#include <stddef.h>
15
24typedef enum {
25 SPI_DOPO_0_SCK_1 = 0,
26 SPI_DOPO_2_SCK_3,
27 SPI_DOPO_3_SCK_1,
28 SPI_DOPO_0_SCK_3,
29} spi_dopo_t;
30
31typedef enum {
32 SPI_DIPO_0 = 0,
33 SPI_DIPO_1,
34 SPI_DIPO_2,
35 SPI_DIPO_3,
36 SPI_DIPO_NONE = 0xff
37} spi_dipo_t;
38
43void spi_init(uint32_t baud);
44
48void spi_enable(void);
49
55uint8_t spi_transfer(uint8_t data);
56
60void spi_disable(void);
61
69void spi_init_instance(uint8_t sercom, spi_dopo_t dopo, spi_dipo_t dipo, uint32_t baud);
70
75void spi_enable_instance(uint8_t sercom);
76
83uint8_t spi_transfer_instance(uint8_t sercom, uint8_t data);
84
89void spi_disable_instance(uint8_t sercom);
90
uint8_t spi_transfer_instance(uint8_t sercom, uint8_t data)
Transfers a byte over SPI.
Definition spi.c:70
void spi_init_instance(uint8_t sercom, spi_dopo_t dopo, spi_dipo_t dipo, uint32_t baud)
Initializes a specific SERCOM instance as an SPI controller.
Definition spi.c:35
void spi_disable_instance(uint8_t sercom)
Disables a specific SERCOM instance for SPI.
Definition spi.c:81
uint8_t spi_transfer(uint8_t data)
Transfers a byte over SPI for a board with a defined SPI_SERCOM.
void spi_enable(void)
Enables the SPI SERCOM for a board with a defined SPI_SERCOM.
void spi_enable_instance(uint8_t sercom)
Enables a specific SERCOM instance for SPI.
Definition spi.c:66
void spi_init(uint32_t baud)
Initializes the SPI SERCOM as a controller for a board with a defined SPI_SERCOM.
void spi_disable(void)
Disables the SPI SERCOM for a board with a defined SPI_SERCOM.