summaryrefslogtreecommitdiff
path: root/mcc_generated_files/spi
diff options
context:
space:
mode:
authorJoshua Drake <joshua.ellis.drake@gmail.com>2025-12-06 14:22:21 -0600
committerJoshua Drake <joshua.ellis.drake@gmail.com>2025-12-06 14:22:21 -0600
commitc9335332df86fbc895a8868a34abcc98817d53f0 (patch)
treeefd0443368c077cbe6215908ae91bf076625e107 /mcc_generated_files/spi
Inital CommitHEADmaster
Diffstat (limited to 'mcc_generated_files/spi')
-rw-r--r--mcc_generated_files/spi/spi0.h176
-rw-r--r--mcc_generated_files/spi/spi_interface.h65
-rw-r--r--mcc_generated_files/spi/spi_polling_types.h49
-rw-r--r--mcc_generated_files/spi/src/spi0.c240
4 files changed, 530 insertions, 0 deletions
diff --git a/mcc_generated_files/spi/spi0.h b/mcc_generated_files/spi/spi0.h
new file mode 100644
index 0000000..b590eaa
--- /dev/null
+++ b/mcc_generated_files/spi/spi0.h
@@ -0,0 +1,176 @@
+/**
+ * SPI0 Generated Driver API Header File
+ *
+ * @file spi0.h
+ *
+ * @defgroup spi0 SPI0
+ *
+ * @brief This header file provides API prototypes for the SPI0 driver.
+ *
+ * @version SPI0 Driver Version 3.1.0
+ *
+ * @version SPI0 Package Version 5.1.0
+*/
+/*
+© [2025] Microchip Technology Inc. and its subsidiaries.
+
+ Subject to your compliance with these terms, you may use Microchip
+ software and any derivatives exclusively with Microchip products.
+ You are responsible for complying with 3rd party license terms
+ applicable to your use of 3rd party software (including open source
+ software) that may accompany Microchip software. SOFTWARE IS ?AS IS.?
+ NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS
+ SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT,
+ MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
+ INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY
+ KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF
+ MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE
+ FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S
+ TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT
+ EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR
+ THIS SOFTWARE.
+*/
+
+#ifndef SPI0_H
+#define SPI0_H
+
+#include <stdbool.h>
+#include "../system/utils/compiler.h"
+#include "spi_interface.h"
+
+/**
+ * @ingroup spi0
+ * @struct SPI_INTERFACE SPI0
+ * @brief SPI driver interface object.
+ */
+extern const struct SPI_INTERFACE SPI0_s;
+
+
+/**
+ * @ingroup spi0
+ * @typedef enum SPI0_configuration_name_t
+ * @brief Enumeration for the different configurations supported by the driver.
+ * A configuration is specified as parameter to SPI0_Open()
+ * and is used by the function to set SPI parameters as specified by the configuration.
+ */
+typedef enum
+{
+ SPI0_DEFAULT
+} SPI0_configuration_name_t;
+
+/**
+ * @ingroup spi0
+ * @brief Initializes the SPI0 module.
+ * @param None.
+ * @return None.
+ */
+void SPI0_Initialize(void);
+
+/**
+ * @ingroup spi0
+ * @brief Deinitializes the SPI0 module
+ * @param None.
+ * @return None.
+ */
+void SPI0_Deinitialize(void);
+
+/**
+ * @ingroup spi0
+ * @brief Enables the SPI0 module with the configurations passed as the parameter.
+ * See spi0_configuration_name_t for the available configurations.
+ * @param spiConfigIndex The Configuration index
+ * @retval True SPI0 module is enabled successfully with the chosen configuration
+ * @retval False SPI0 module is already open with another configuration
+ */
+bool SPI0_Open(uint8_t spiConfigIndex);
+
+/**
+ * @ingroup spi0
+ * @brief Closes the active configuration of the SPI0 module.
+ * @param None.
+ * @return None.
+ */
+void SPI0_Close(void);
+
+/**
+ * @ingroup spi0
+ * @brief Exchanges one byte using the SPI protocol. This function is blocking.
+ * @param byteData The byte to be written
+ * @return Received data byte
+ */
+uint8_t SPI0_ByteExchange(uint8_t byteData);
+
+/**
+ * @ingroup spi0
+ * @brief Exchanges the buffer using the SPI protocol with separate transmit and receive buffer locations. This function is blocking in Polling mode.
+ * @param [in] *txBuffer Buffer address of the data to be transmitted during exchange
+ * @param [in] *rxBuffer Buffer address of the data to be received during exchange
+ * @param [in] bufferSize Size of the data in bytes
+ * @return None.
+ */
+void SPI0_Transfer(const void * txBuffer, void * rxBuffer, size_t bufferSize);
+
+/**
+ * @ingroup spi0
+ * @brief Exchanges the buffer using the SPI protocol. This function is blocking in Polling mode.
+ * @param [in,out] *bufferData Buffer address of the data to be exchanged
+ * @param [in] bufferSize Size of the data in bytes
+ * @return None.
+ */
+void SPI0_BufferExchange(void * bufferData, size_t bufferSize);
+
+/**
+ * @ingroup spi0
+ * @brief Writes a buffer using the SPI protocol. This function is blocking in Polling mode.
+ * @param [in] *bufferData Buffer address of the data to be written
+ * @param [in] bufferSize Size of the data in bytes
+ * @return None.
+ */
+void SPI0_BufferWrite(void * bufferData, size_t bufferSize);
+
+/**
+ * @ingroup spi0
+ * @brief Reads a buffer using the SPI protocol. This function is blocking in Polling mode.
+ * @param [out] *bufferData Buffer address of the data to be read
+ * @param [in] bufferSize Size of the data in bytes
+ * @return None.
+ */
+void SPI0_BufferRead(void * bufferData, size_t bufferSize);
+
+/**
+ * @ingroup spi0
+ * @brief Writes one byte using the SPI protocol. This function is blocking in Polling mode.
+ * @param byteData The byte to be written
+ * @return None.
+ */
+void SPI0_ByteWrite(uint8_t byteData);
+
+/**
+ * @ingroup spi0
+ * @brief Receives one byte using SPI protocol. This function is blocking.
+ * @param None.
+ * @return Received data byte
+ */
+uint8_t SPI0_ByteRead(void);
+
+/**
+ * @ingroup spi0
+ * @brief Checks if the SPI0 module is ready to read data.
+ * @param None.
+ * @retval True SPI0 module has data ready in buffer
+ * @retval False SPI0 module is not ready to read data
+ */
+bool SPI0_IsRxReady(void);
+
+/**
+ * @ingroup spi0
+ * @brief Checks if the SPI0 module is ready to write data.
+ * @param None.
+ * @retval True SPI0 module is ready to write data
+ * @retval False SPI0 module is not ready to write data
+ */
+bool SPI0_IsTxReady(void);
+
+
+#endif /* SPI0_H */
diff --git a/mcc_generated_files/spi/spi_interface.h b/mcc_generated_files/spi/spi_interface.h
new file mode 100644
index 0000000..1ea91dd
--- /dev/null
+++ b/mcc_generated_files/spi/spi_interface.h
@@ -0,0 +1,65 @@
+/**
+ * SPI Driver API Interface File
+ *
+ * @file spi_interface.h
+ *
+ * @defgroup spi SPI
+ *
+ * @brief This header file provides API prototypes for the SPI module in Polling and Interrupt mode.
+ *
+ * @version SPI Interface Version v3.1.0
+*/
+
+/*
+© [2025] Microchip Technology Inc. and its subsidiaries.
+
+ Subject to your compliance with these terms, you may use Microchip
+ software and any derivatives exclusively with Microchip products.
+ You are responsible for complying with 3rd party license terms
+ applicable to your use of 3rd party software (including open source
+ software) that may accompany Microchip software. SOFTWARE IS ?AS IS.?
+ NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS
+ SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT,
+ MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
+ INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY
+ KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF
+ MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE
+ FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S
+ TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT
+ EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR
+ THIS SOFTWARE.
+*/
+
+#ifndef SPI_INTERFACE_H
+#define SPI_INTERFACE_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <stddef.h>
+
+/**
+ * @ingroup spi
+ * @struct SPI_INTERFACE SPI
+ * @brief SPI Driver prototypes struct.
+ */
+struct SPI_INTERFACE
+{
+ void (*Initialize)(void);
+ void (*Deinitialize)(void);
+ bool (*Open)(uint8_t spiConfigIndex);
+ void (*Close)(void);
+ void (*Transfer)(const void *txBuffer, void *rxBuffer, size_t bufferSize);
+ void (*BufferExchange)(void *bufferData, size_t bufferSize);
+ void (*BufferRead)(void *bufferData, size_t bufferSize);
+ void (*BufferWrite)(void *bufferData, size_t bufferSize);
+ uint8_t (*ByteExchange)(uint8_t byteData);
+ uint8_t (*ByteRead)(void);
+ void (*ByteWrite)(uint8_t byteData);
+ bool (*IsRxReady)(void);
+ bool (*IsTxReady)(void);
+ void (*RxCompleteCallbackRegister)(void (*callbackHandler)(void));
+ void (*TxCompleteCallbackRegister)(void (*callbackHandler)(void));
+};
+
+#endif /* SPI_INTERFACE_H */
diff --git a/mcc_generated_files/spi/spi_polling_types.h b/mcc_generated_files/spi/spi_polling_types.h
new file mode 100644
index 0000000..4bc07f7
--- /dev/null
+++ b/mcc_generated_files/spi/spi_polling_types.h
@@ -0,0 +1,49 @@
+/**
+ * SPI Type Definitions Header File
+ *
+ * @file spi_polling_types.h
+ *
+ * @defgroup spi SPI
+ *
+ * @brief This header file provides type definitions for the SPI module operation in Polling mode.
+ *
+ * @version SPI Driver Version 3.1.0
+*/
+
+/*
+© [2025] Microchip Technology Inc. and its subsidiaries.
+
+ Subject to your compliance with these terms, you may use Microchip
+ software and any derivatives exclusively with Microchip products.
+ You are responsible for complying with 3rd party license terms
+ applicable to your use of 3rd party software (including open source
+ software) that may accompany Microchip software. SOFTWARE IS ?AS IS.?
+ NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS
+ SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT,
+ MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
+ INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY
+ KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF
+ MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE
+ FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S
+ TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT
+ EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR
+ THIS SOFTWARE.
+*/
+
+#ifndef SPI_POLLING_TYPES_H
+#define SPI_POLLING_TYPES_H
+
+
+/**
+ * @ingroup spi
+ * @typedef struct spi_configuration_t
+ * @brief Holds register configurations for SPI module.
+ */
+typedef struct
+{
+ uint8_t ctrla;
+ uint8_t ctrlb;
+} spi_configuration_t;
+
+#endif /* SPI_POLLING_TYPES_H */
diff --git a/mcc_generated_files/spi/src/spi0.c b/mcc_generated_files/spi/src/spi0.c
new file mode 100644
index 0000000..ba16982
--- /dev/null
+++ b/mcc_generated_files/spi/src/spi0.c
@@ -0,0 +1,240 @@
+/**
+ * SPI0 Generated Driver File
+ *
+ * @file spi0.c
+ *
+ * @ingroup spi0
+ *
+ * @brief This file contains the driver code for the SPI0 module.
+ *
+ * @version SPI0 Driver Version 3.1.0
+ *
+ * @version SPI0 Package Version 5.1.0
+*/
+/*
+© [2025] Microchip Technology Inc. and its subsidiaries.
+
+ Subject to your compliance with these terms, you may use Microchip
+ software and any derivatives exclusively with Microchip products.
+ You are responsible for complying with 3rd party license terms
+ applicable to your use of 3rd party software (including open source
+ software) that may accompany Microchip software. SOFTWARE IS ?AS IS.?
+ NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS
+ SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT,
+ MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
+ INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY
+ KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF
+ MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE
+ FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP?S
+ TOTAL LIABILITY ON ALL CLAIMS RELATED TO THE SOFTWARE WILL NOT
+ EXCEED AMOUNT OF FEES, IF ANY, YOU PAID DIRECTLY TO MICROCHIP FOR
+ THIS SOFTWARE.
+*/
+
+
+#include "../spi0.h"
+#include "../spi_polling_types.h"
+
+const struct SPI_INTERFACE SPI0_s =
+{
+ .Initialize = SPI0_Initialize,
+ .Deinitialize = SPI0_Deinitialize,
+ .Open = SPI0_Open,
+ .Close = SPI0_Close,
+ .Transfer = SPI0_Transfer,
+ .BufferExchange = SPI0_BufferExchange,
+ .BufferWrite = SPI0_BufferWrite,
+ .BufferRead = SPI0_BufferRead,
+ .ByteExchange = SPI0_ByteExchange,
+ .ByteWrite = SPI0_ByteWrite,
+ .ByteRead = SPI0_ByteRead,
+ .IsTxReady = SPI0_IsTxReady,
+ .IsRxReady = SPI0_IsRxReady,
+ .RxCompleteCallbackRegister = NULL,
+ .TxCompleteCallbackRegister = NULL
+};
+
+static const spi_configuration_t spi0_configuration[] =
+{
+ { 0x34, 0xC4 }
+};
+
+void SPI0_Initialize(void)
+{
+ SPI0.CTRLA &= ~SPI_ENABLE_bm;
+ SPI0.CTRLA = (1 << SPI_CLK2X_bp) /* CLK2X (enabled) */
+ |(0 << SPI_DORD_bp) /* DORD (disabled) */
+ |(0 << SPI_ENABLE_bp) /* ENABLE (disabled) */
+ |(1 << SPI_MASTER_bp) /* MASTER (enabled) */
+ |(SPI_PRESC_DIV64_gc); /* PRESC (DIV64) */
+ SPI0.CTRLB = (1 << SPI_BUFEN_bp) /* BUFEN (enabled) */
+ |(1 << SPI_BUFWR_bp) /* BUFWR (enabled) */
+ |(SPI_MODE_0_gc) /* MODE (0) */
+ |(1 << SPI_SSD_bp); /* SSD (enabled) */
+}
+
+void SPI0_Deinitialize(void)
+{
+ SPI0.CTRLA = 0x0;
+ SPI0.CTRLB = 0x0;
+ SPI0.INTCTRL = 0x0;
+}
+
+bool SPI0_Open(uint8_t spiConfigIndex)
+{
+ bool returnValue = false;
+ if (0 == (SPI0.CTRLA & SPI_ENABLE_bm))
+ {
+ SPI0.CTRLB = spi0_configuration[spiConfigIndex].ctrlb;
+ SPI0.CTRLA = spi0_configuration[spiConfigIndex].ctrla;
+ SPI0.CTRLA |= SPI_ENABLE_bm;
+ returnValue = true;
+ }
+ else
+ {
+ returnValue = false;
+ }
+ return returnValue;
+}
+
+void SPI0_Close(void)
+{
+ SPI0.CTRLA &= ~SPI_ENABLE_bm;
+}
+
+uint8_t SPI0_ByteExchange(uint8_t byteData)
+{
+ uint8_t readData = 0;
+ SPI0.DATA = byteData;
+ while (0 == (SPI0.INTFLAGS & SPI_RXCIF_bm))
+ {
+ ; // Wait until ongoing SPI transfer is completed
+ }
+ readData = SPI0.DATA;
+ return readData;
+}
+
+void SPI0_ByteWrite(uint8_t byteData)
+{
+ SPI0.DATA = byteData;
+}
+
+uint8_t SPI0_ByteRead(void)
+{
+ return SPI0.DATA;
+}
+
+void SPI0_Transfer(const void *txBuffer, void *rxBuffer, size_t bufferSize)
+{
+ const uint8_t *bufferTransmit = (const uint8_t *)txBuffer;
+ uint8_t *bufferReceive = (uint8_t *)rxBuffer;
+ size_t bufferInputSize = bufferSize;
+ while(0U != bufferInputSize)
+ {
+ SPI0.DATA = *bufferTransmit;
+ while (0 == (SPI0.INTFLAGS & SPI_RXCIF_bm))
+ {
+ ; // Wait until ongoing SPI transfer is completed
+ }
+ *bufferReceive = SPI0.DATA;
+ bufferTransmit++;
+ bufferReceive++;
+ bufferInputSize--;
+ }
+}
+
+void SPI0_BufferExchange(void *bufferData, size_t bufferSize)
+{
+ uint8_t *buffer = (uint8_t *)bufferData;
+ size_t bufferInputSize = bufferSize;
+ while(0U != bufferInputSize)
+ {
+ SPI0.DATA = *buffer;
+ while (0 == (SPI0.INTFLAGS & SPI_RXCIF_bm))
+ {
+ ; // Wait until ongoing SPI transfer is completed
+ }
+ *buffer = SPI0.DATA;
+ buffer++;
+ bufferInputSize--;
+ }
+}
+
+void SPI0_BufferWrite(void *bufferData, size_t bufferSize)
+{
+ uint8_t *buffer = (uint8_t *)bufferData;
+ uint8_t readData = 0;
+ size_t bufferInputSize = bufferSize;
+ while(0U != bufferInputSize)
+ {
+ SPI0.DATA = *buffer;
+ while(0 == (SPI0.INTFLAGS & SPI_RXCIF_bm))
+ {
+ ; // Wait until ongoing SPI transfer is completed
+ }
+ readData = SPI0.DATA;
+ (void) readData;
+ buffer++;
+ bufferInputSize--;
+ }
+}
+
+void SPI0_BufferRead(void *bufferData, size_t bufferSize)
+{
+ uint8_t *buffer = (uint8_t *)bufferData;
+ size_t bufferInputSize = bufferSize;
+ while(0U != bufferInputSize)
+ {
+ SPI0.DATA = 0;
+ while (0 == (SPI0.INTFLAGS & SPI_RXCIF_bm))
+ {
+ ; // Wait until ongoing SPI transfer is completed
+ }
+ *buffer = SPI0.DATA;
+ buffer++;
+ bufferInputSize--;
+ }
+}
+
+bool SPI0_IsTxReady(void)
+{
+ bool returnValue = false;
+ if(0 != (SPI0.CTRLA & SPI_ENABLE_bm))
+ {
+ if(0 != (SPI0.INTFLAGS & SPI_DREIF_bm))
+ {
+ returnValue = true;
+ }
+ else
+ {
+ returnValue = false;
+ }
+ }
+ else
+ {
+ returnValue = false;
+ }
+ return returnValue;
+}
+
+bool SPI0_IsRxReady(void)
+{
+ bool returnValue = false;
+ if(0 != (SPI0.CTRLA & SPI_ENABLE_bm))
+ {
+ if(0 != (SPI0.INTFLAGS & SPI_RXCIF_bm))
+ {
+ returnValue = true;
+ }
+ else
+ {
+ returnValue = false;
+ }
+ }
+ else
+ {
+ returnValue = false;
+ }
+ return returnValue;
+} \ No newline at end of file