From 2f88d83c01b91e490e4fbcbca820c175d93c8012 Mon Sep 17 00:00:00 2001 From: Luke Date: Thu, 7 Dec 2023 19:01:11 -0500 Subject: [PATCH] Comment L4 PHAL --- common/phal_L4/adc/adc.h | 36 ++-- common/phal_L4/can/can.c | 2 +- common/phal_L4/can/can.h | 25 ++- common/phal_L4/dma/dma.h | 51 +++-- common/phal_L4/eeprom_spi/eeprom_spi.c | 272 +++++++++++++------------ common/phal_L4/eeprom_spi/eeprom_spi.h | 9 + common/phal_L4/flash/flash.h | 13 +- common/phal_L4/gpio/gpio.c | 16 +- common/phal_L4/gpio/gpio.h | 49 +++-- 9 files changed, 275 insertions(+), 198 deletions(-) diff --git a/common/phal_L4/adc/adc.h b/common/phal_L4/adc/adc.h index aa91c8b0..b245975d 100644 --- a/common/phal_L4/adc/adc.h +++ b/common/phal_L4/adc/adc.h @@ -1,7 +1,7 @@ /** * @file adc.h * @author Luke Oxley (lcoxley@purdue.edu) - * @brief + * @brief ADC HAL for STM32L4 MCU * @version 0.1 * @date 2021-12-27 */ @@ -13,7 +13,7 @@ #include #define PHAL_ADC_INIT_TIMEOUT 1000000 -#define PHAL_ADC_CR_BITS_RS 0b10000000000000000000000000111111 +#define PHAL_ADC_CR_BITS_RS 0x8000003F typedef enum { ADC_RES_12_BIT = 0b00, @@ -38,29 +38,36 @@ typedef enum { } ADCClkPrescaler_t; typedef enum { - ADC_DMA_OFF = 0b00, - ADC_DMA_ONE_SHOT = 0b01, - ADC_DMA_CIRCULAR = 0b11 + ADC_DMA_OFF = 0b00, //!< ADC performs no conversion + ADC_DMA_ONE_SHOT = 0b01, //!< ADC performs single conversion + ADC_DMA_CIRCULAR = 0b11 //!< ADC conitinuously converts } ADCDMAMode_t; +/** Data bit alignment within the conversion */ typedef enum { ADC_DATA_ALIGN_RIGHT = 0b0, ADC_DATA_ALIGN_LEFT = 0b1 } ADCDataAlign_t; +/** Top-level ADC configuration */ typedef struct { - ADCClkPrescaler_t clock_prescaler; // required to have high enough prescaler to operate within ADC maximum freq - ADCResolution_t resolution; // bit resolution of readings - ADCDataAlign_t data_align; + ADCClkPrescaler_t clock_prescaler; //!< required to have high enough prescaler to operate within ADC maximum freq + ADCResolution_t resolution; //!< Bit resolution of readings + ADCDataAlign_t data_align; //!< Data bit alignment within the conversion //uint32_t ext_trig_conv; //uint32_t ext_trig_conv_edge; - bool cont_conv_mode; + bool cont_conv_mode; //!< ADC restarts conversions once complete //bool discont_conv_mode; - bool overrun; // set true if data register can be overwritten before being read + bool overrun; //!< Set true if data register can be overwritten before being read //uint32_t nbr_of_disc_conv; - ADCDMAMode_t dma_mode; + ADCDMAMode_t dma_mode; //!< ADC DMA mode } ADCInitConfig_t; +/** + * Duration of the sample in ADC clock cycles. + * A longer conversion time allows the internal + * measurement capacitor to fully charge. +*/ typedef enum { ADC_CHN_SMP_CYCLES_2_5 = 0b000, ADC_CHN_SMP_CYCLES_6_5 = 0b001, @@ -72,10 +79,11 @@ typedef enum { ADC_CHN_SMP_CYCLES_640_5 = 0b111, } ADCChannelSampleCycles_t; +/** ADC configuration for one channel */ typedef struct { - uint32_t channel; // not the GPIO channel, use the ADC channel (ie. PA0 = channel 5) - uint32_t rank; // order at which the channels will be polled, starting at 1 - ADCChannelSampleCycles_t sampling_time; // 2_5 works, set higher for large imedances + uint32_t channel; //!< not the GPIO channel, use the ADC channel (ie. PA0 = channel 5) + uint32_t rank; //!< order at which the channels will be polled, starting at 1 + ADCChannelSampleCycles_t sampling_time; //!< Set higher for large impedances //uint32_t single_diff; //uint32_t offset_num; //uint32_t offset; diff --git a/common/phal_L4/can/can.c b/common/phal_L4/can/can.c index a0955564..c0106090 100644 --- a/common/phal_L4/can/can.c +++ b/common/phal_L4/can/can.c @@ -1,5 +1,5 @@ /** - * @file hal_can_f4.c + * @file can.c * @author Adam Busch (busch8@purdue.edu) * @brief Basic CAN Peripheral HAL library for setting up CAN peripheral and sending messages * @version 0.1 diff --git a/common/phal_L4/can/can.h b/common/phal_L4/can/can.h index 9cd8e1ed..59f575ff 100644 --- a/common/phal_L4/can/can.h +++ b/common/phal_L4/can/can.h @@ -16,10 +16,10 @@ #include -#define PHAL_CAN_TX_TIMEOUT (5000U) -#define PHAL_CAN_INIT_TIMEOUT (5000U) +#define PHAL_CAN_TX_TIMEOUT (5000U) //!< in milliseconds +#define PHAL_CAN_INIT_TIMEOUT (5000U) //!< in milliseconds -// Bit timing recovered from http://www.bittiming.can-wiki.info/ +/** Bit timing recovered from http://www.bittiming.can-wiki.info/ */ #define PHAL_CAN_16MHz_500k (0x001c0001) #define PHAL_CAN_20MHz_500k (0x00050004) #define PHAL_CAN_40MHz_500k (0x001c0004) @@ -27,17 +27,18 @@ typedef struct { - CAN_TypeDef* Bus; /*!< Specifies the bus. */ - uint16_t StdId; /*!< Specifies the standard identifier. */ - uint32_t ExtId; /*!< Specifies the extended identifier. */ - uint32_t IDE; /*!< Specifies the type of identifier for the message that will be transmitted. */ - uint32_t DLC; /*!< Specifies the length of the frame that will be transmitted. */ - uint8_t Data[8]; /*!< Contains the data to be transmitted. */ + CAN_TypeDef* Bus; //!< Specifies the bus. + uint16_t StdId; //!< Specifies the standard identifier. + uint32_t ExtId; //!< Specifies the extended identifier. + uint32_t IDE; //!< Specifies the type of identifier for the message that will be transmitted. + uint32_t DLC; //!< Specifies the length of the frame that will be transmitted. + uint8_t Data[8]; //!< Contains the data to be transmitted. */ } CanMsgTypeDef_t; /** * @brief Initilize CAN peripheral to 500k. * + * @param bus The CAN peripheral to initialize (i.e. CAN1) * @param test_mode Initilize CAN peripheral for self test mode * * @return true Peripheral sucessfully initalized @@ -45,6 +46,12 @@ typedef struct */ bool PHAL_initCAN(CAN_TypeDef* bus, bool test_mode); +/** + * @brief De-initialize the CAN peripheral + * + * @param bus The CAN peripheral to de-initialize (i.e. CAN1) + * @return Perihperal succesfully de-initialized + */ bool PHAL_deinitCAN(CAN_TypeDef* bus); /** diff --git a/common/phal_L4/dma/dma.h b/common/phal_L4/dma/dma.h index 399e9a72..766f1b59 100644 --- a/common/phal_L4/dma/dma.h +++ b/common/phal_L4/dma/dma.h @@ -1,3 +1,13 @@ +/** + * @file dma.h + * @author Dawson Moore (moore800@purdue.edu) + * @brief Basic DMA Peripheral HAL library for setting up DMA transfers + * @version 0.1 + * @date 2022-01-10 + * + * @copyright Copyright (c) 2021 + * + */ #ifndef _DMA_H_ #define _DMA_H_ @@ -11,30 +21,31 @@ #include +/** Top-level DMA configuration */ typedef struct { - uint32_t periph_addr; - uint32_t mem_addr; - uint16_t tx_size; + uint32_t periph_addr; //!< Address of the peripheral location (or other memory location in mem-to-mem) to transfer from/to + uint32_t mem_addr; //!< Address of the memory location to transfer from/to + uint16_t tx_size; //!< Number of transfers to complete in sizes set by mem / periph size bool increment; - bool circular; - uint8_t dir; - bool mem_inc; - bool periph_inc; - bool mem_to_mem; - uint8_t priority; - uint8_t mem_size; - uint8_t periph_size; - bool tx_isr_en; - uint8_t dma_chan_request; /* Table 44 of Family Reference */ - uint8_t channel_idx; + bool circular; //!< Continuously transfer + uint8_t dir; //!< If set to 0, transfers from periph_addr to mem_addr. If 1, opposite direction. + bool mem_inc; //!< Increment mem_addr after each transfer + bool periph_inc; //!< Increment periph_addr after each transfer + bool mem_to_mem; //!< If both locations are memory locations + uint8_t priority; //!< Transfer priority + uint8_t mem_size; //!< Size to read from mem_addr (00 = 8 bits, 01 = 16 bits, 10 = 32 bits) + uint8_t periph_size; //!< Size to read form periph_addr (00 = 8 bits, 01 = 16 bits, 10 = 32 bits) + bool tx_isr_en; //!< Enable the TX ISR + uint8_t dma_chan_request; //!< Table 44 of Family Reference */ + uint8_t channel_idx; //!< DMA Channel (Table 44 of Family Reference) DMA_TypeDef* periph; DMA_Channel_TypeDef* channel; DMA_Request_TypeDef* request; } dma_init_t; -/* +/** * @brief Initialize DMA peripheral to set m2m, p2p, or p2m with set size * and length of txfer * @@ -44,35 +55,35 @@ typedef struct { */ bool PHAL_initDMA(dma_init_t* init); -/* +/** * @brief Start txfer after sucessful DMA peripheral initialization * * @param init -> Address of initialization structure */ void PHAL_startTxfer(dma_init_t* init); -/* +/** * @brief Stop txfer * * @param init -> Address of initialization structure */ void PHAL_stopTxfer(dma_init_t* init); -/* +/** * @brief Re-enable DMA txfer after error ISR fires * * @param init -> Address of initialization structure */ void PHAL_reEnable(dma_init_t* init); -/* +/** * @brief Set memory address for DMA transfer. In Mem to Mem this acts as the source address * * @param init -> Address of initialization structure */ void PHAL_DMA_setMemAddress(dma_init_t* init, const uint32_t address); -/* +/** * @brief Set transfer length for DMA transaction * * @param init -> Address of initialization structure diff --git a/common/phal_L4/eeprom_spi/eeprom_spi.c b/common/phal_L4/eeprom_spi/eeprom_spi.c index cd55e12f..adb15e18 100644 --- a/common/phal_L4/eeprom_spi/eeprom_spi.c +++ b/common/phal_L4/eeprom_spi/eeprom_spi.c @@ -1,12 +1,21 @@ +/** + * @file eeprom_spi.c + * @author Luke Oxley (lcoxley@purdue.edu), modification of Dawson Moore's eeprom.c for SPI support + * @version 0.1 + * @date 2022-12-01 + * + * @copyright Copyright (c) 2022 + * + */ #include "common/phal_L4/eeprom_spi/eeprom_spi.h" // Local defines -#define E_READ 0x03 // Read data from memory beginning at selected address -#define E_WRITE 0x02 // Write data to memory beginning at selected address -#define E_WRDI 0x04 // Reset the write enable latch (disable write operations) -#define E_WREN 0x06 // Set the write enable latch (enable write operations) -#define E_RDSR 0x05 // Read STATUS register -#define E_WRSR 0x01 // Write STATUS register +#define E_READ 0x03 //!< Read data from memory beginning at selected address +#define E_WRITE 0x02 //!< Write data to memory beginning at selected address +#define E_WRDI 0x04 //!< Reset the write enable latch (disable write operations) +#define E_WREN 0x06 //!< Set the write enable latch (enable write operations) +#define E_RDSR 0x05 //!< Read STATUS register +#define E_WRSR 0x01 //!< Write STATUS register // EEPROM struct struct eeprom mem; @@ -26,19 +35,19 @@ static uint8_t ee_get_idx(uint32_t *req); static void ee_clear_idx(uint32_t *req, uint8_t idx); static void ee_request_flush_physical(); -// @funcname: initMem -// -// @brief: Initializes chip metadata. Attemps to read -// and load all metadata from last run. If memory -// isn't initialized, force_init can be set to -// set a default version of 1 and mark the chip -// as officially in use -// -// @param: wc_gpio_port: Mem lock port0 -// @param: wc_gpio_pin: Mem lock pin -// @param: version: Version of app code -// @param: force_init: Force initialization if memory isn't -// initialized. Only set if version is truly 1 +/** + * @brief: Initializes chip metadata. Attemps to read + * and load all metadata from last run. If memory + * isn't initialized, force_init can be set to + * set a default version of 1 and mark the chip + * as officially in use + * + * @param: wc_gpio_port: Mem lock port0 + * @param: wc_gpio_pin: Mem lock pin + * @param: version: Version of app code + * @param: force_init: Force initialization if memory isn't + * initialized. Only set if version is truly 1 + */ int initMem(GPIO_TypeDef* wc_gpio_port, uint32_t wc_gpio_pin, SPI_InitConfig_t* spi, uint16_t version, bool force_init) { int ret; uint16_t i, size, end; @@ -108,17 +117,17 @@ int initMem(GPIO_TypeDef* wc_gpio_port, uint32_t wc_gpio_pin, SPI_InitConfig_t* return E_SUCCESS; } -// @funcname: checkVersion -// -// @brief: Checks version to ensure app code is new enough -// -// @param: dest: Pointer to location to set -// @param: len: Length to set -// @param: value: Value to set each memory address to -// @param: Difference between current and chip versions -// if app code is newer, -E_V_MISMATCH if app -// code is old. -E_NO_INIT if memory hasn't -// been initialized yet +/** + * @brief: Checks version to ensure app code is new enough + * + * @param: dest: Pointer to location to set + * @param: len: Length to set + * @param: value: Value to set each memory address to + * @param: Difference between current and chip versions + * if app code is newer, -E_V_MISMATCH if app + * code is old. -E_NO_INIT if memory hasn't + * been initialized yet + */ int checkVersion(uint16_t version) { // Check if we're even initialized if (mem.phys.init_key != INIT_KEY) { @@ -133,14 +142,14 @@ int checkVersion(uint16_t version) { } } -// @funcname: mapMem -// -// @brief: Maps local address to chip address -// -// @param: addr: Pointer to local address -// @param: len: Length of data -// @param: fname: File name (NAME_LEN characters) -// @param: bcmp: Backwards compatibility enabled. Disable for temp storage +/** + * @brief: Maps local address to chip address + * + * @param: addr: Pointer to local address + * @param: len: Length of data + * @param: fname: File name (NAME_LEN characters) + * @param: bcmp: Backwards compatibility enabled. Disable for temp storage + */ int mapMem(uint8_t* addr, uint16_t len, uint8_t* fname, bool bcmp) { int i; uint8_t null_name[NAME_LEN], ret; @@ -224,14 +233,14 @@ static uint8_t curr_page; static uint32_t addr; static BG_State bg_state; -// @funcname: memBg -// -// @brief: Background task for searching for stale data -// If metadata or any mapped struct is updated, -// it will be written to the device once searched -// by the foreground loop -// -// @note: Application code must add to background queue with rate MEM_FG_TIME +/** + * @brief: Background task for searching for stale data + * If metadata or any mapped struct is updated, + * it will be written to the device once searched + * by the foreground loop + * + * @note: Application code must add to background queue with rate MEM_FG_TIME + */ void memBg(void) { int ret; static uint8_t page[MICRO_PG_SIZE]; @@ -345,11 +354,11 @@ void memBg(void) { } } -// @funcname: memFg -// -// @brief: Foreground routine for 5ms write coherency -// -// @note: Application code must add to foreground queue +/** + * @brief: Foreground routine for 5ms write coherency + * + * @note: Application code must add to foreground queue + */ void memFg(void) { if (!mem.write_pending) { return; @@ -360,17 +369,17 @@ void memFg(void) { mem.write_pending = false; // TODO: Since this is called t 5ms, should be okay to set here... } -// @funcname: readMem -// -// @brief: Reads memory across micro page boundaries -// Blocks until data fully read -// Assumes phys_addr is a page_bd -// -// @param: phys_addr: On chip address of data -// @param: loc_addr: Local address of data -// @param: len: Length of data -// -// @return: E_SUCCESS if read, error code if failed +/** + * @brief: Reads memory across micro page boundaries + * Blocks until data fully read + * Assumes phys_addr is a page_bd + * + * @param: phys_addr: On chip address of data + * @param: loc_addr: Local address of data + * @param: len: Length of data + * + * @return: E_SUCCESS if read, error code if failed + */ static int readMem(uint16_t phys_addr, uint8_t* loc_addr, uint16_t len) { int ret; uint8_t page[MICRO_PG_SIZE]; @@ -397,17 +406,17 @@ static int readMem(uint16_t phys_addr, uint8_t* loc_addr, uint16_t len) { return E_SUCCESS; } -// @funcname: writePage -// -// @brief: Writes a single micro page to chip -// Must wait 5ms between calls -// Fails if SPI busy -// -// @param: addr: On chip address of data -// @param: page: Pointer to data to write -// @param: size: Length of write (capped at MICRO_PG_SIZE) -// -// @note: E_SUCCESS if written, -E_SPI if failed +/** + * @brief: Writes a single micro page to chip + * Must wait 5ms between calls + * Fails if SPI busy + * + * @param: addr: On chip address of data + * @param: page: Pointer to data to write + * @param: size: Length of write (capped at MICRO_PG_SIZE) + * + * @note: E_SUCCESS if written, -E_SPI if failed + */ int writePage(uint16_t addr, uint8_t* page, uint8_t size) { uint8_t ret; @@ -439,15 +448,15 @@ int writePage(uint16_t addr, uint8_t* page, uint8_t size) { return ret ? -E_SPI : E_SUCCESS; } -// @funcname: readPage -// -// @brief: Reads a single micro page from chip -// Fails if SPI busy -// -// @param: addr: On chip address of data -// @param: page: Pointer to returned data -// -// @param: E_SUCCESS if read, -E_SPI if failed +/** +* @brief: Reads a single micro page from chip +* Fails if SPI busy +* +* @param: addr: On chip address of data +* @param: page: Pointer to returned data +* +* @param: E_SUCCESS if read, -E_SPI if failed +*/ int readPage(uint16_t addr, uint8_t* page) { uint8_t ret; @@ -495,22 +504,22 @@ void requestFlush(char* name) } } -// @funcname: memClear -// -// @brief: Clears all addresses to 0 on chip +/** + * @brief: Clears all addresses to 0 on chip + */ static void memClear() { mem.zero_req = true; } -// @funcname: memTest -// -// @brief: Fill chip with ones and check each location -// to ensure writes were complete -// -// @return: E_SUCCESS if memory matches, -E_M_MISMATCH -// -// @note: DO NOT USE! WILL RESET STRUCTS AND CAUSE DEVICE -// NAKS FOLLOWED BY I2C STOPPAGE +/** + * @brief: Fill chip with ones and check each location + * to ensure writes were complete + * + * @return: E_SUCCESS if memory matches, -E_M_MISMATCH + * + * @note: DO NOT USE! WILL RESET STRUCTS AND CAUSE DEVICE + * NAKS FOLLOWED BY I2C STOPPAGE + */ static int memTest() { size_t i; uint8_t one[MICRO_PG_SIZE]; @@ -533,15 +542,15 @@ static int memTest() { return E_SUCCESS; } -// @funcname: fnameSearch -// -// @brief: Find index -// -// @param: dest: Pointer to location to set -// @param: len: Length to set -// @param: value: Value to set each memory address to -// -// @return: Index of name if it exists, -E_NO_NAME else +/** +* @brief: Find index +* +* @param: dest: Pointer to location to set +* @param: len: Length to set +* @param: value: Value to set each memory address to +* +* @return: Index of name if it exists, -E_NO_NAME else +*/ static int fnameSearch(char* name) { uint8_t i; @@ -555,15 +564,15 @@ static int fnameSearch(char* name) { return -E_NO_NAME; } -// @funcname: ee_memcheck -// -// @brief: Simple memcheck routine -// -// @param: src: Pointer to location to check -// @param: dest: Pointer to second location to check -// @param: len: Length to check -// -// @return: E_SUCCESS if memory matches, -E_M_MISMATCH else +/** + * @brief: Simple memcheck routine + * + * @param: src: Pointer to location to check + * @param: dest: Pointer to second location to check + * @param: len: Length to check + * + * @return: E_SUCCESS if memory matches, -E_M_MISMATCH else + */ static int ee_memcheck(uint8_t* src, uint8_t* dest, size_t len) { size_t i; @@ -576,13 +585,13 @@ static int ee_memcheck(uint8_t* src, uint8_t* dest, size_t len) { return E_SUCCESS; } -// @funcname: ee_memset -// -// @brief: Simple memset routine -// -// @param: dest: Pointer to location to set -// @param: len: Length to set -// @param: value: Value to set each memory address to +/** + * @brief: Simple memset routine + * + * @param: dest: Pointer to location to set + * @param: len: Length to set + * @param: value: Value to set each memory address to + */ static void ee_memset(uint8_t* dest, size_t len, uint8_t value) { size_t i; @@ -591,13 +600,13 @@ static void ee_memset(uint8_t* dest, size_t len, uint8_t value) { } } -// @funcname: ee_memcpy -// -// @brief: Simple memcpy routine -// -// @param: src: Pointer to location to copy -// @param: dest: Pointer to location from which to copy -// @param: len: Length of data to copy +/** + * @brief: Simple memcpy routine + * + * @param: src: Pointer to location to copy + * @param: dest: Pointer to location from which to copy + * @param: len: Length of data to copy + */ static void ee_memcpy(uint8_t* src, uint8_t* dest, size_t len) { size_t i; @@ -606,7 +615,10 @@ static void ee_memcpy(uint8_t* src, uint8_t* dest, size_t len) { } } -// gets index of first set bit, assumes a bit is set +/** + * @brief gets index of first set bit, assumes a bit is set + * + */ static uint8_t ee_get_idx(uint32_t *req) { uint8_t idx = 0; @@ -629,7 +641,9 @@ static uint8_t ee_get_idx(uint32_t *req) return idx; } -// clears bit at index +/** + * @brief clears bit at index + */ static void ee_clear_idx(uint32_t *req, uint8_t idx) { if (idx < 32) @@ -646,4 +660,4 @@ static void ee_request_flush_physical() addr = 0; curr_page = 0; } -} \ No newline at end of file +} diff --git a/common/phal_L4/eeprom_spi/eeprom_spi.h b/common/phal_L4/eeprom_spi/eeprom_spi.h index aded9297..36b082bc 100644 --- a/common/phal_L4/eeprom_spi/eeprom_spi.h +++ b/common/phal_L4/eeprom_spi/eeprom_spi.h @@ -1,3 +1,12 @@ +/** + * @file eeprom_spi.h + * @author Luke Oxley (lcoxley@purdue.edu), modification of Dawson Moore's eeprom.c for SPI support + * @version 0.1 + * @date 2022-12-01 + * + * @copyright Copyright (c) 2022 + * + */ #ifndef _PHAL_EEPROM_SPI_H_ #define _PHAL_EEPROM_SPI_H_ diff --git a/common/phal_L4/flash/flash.h b/common/phal_L4/flash/flash.h index 3bcdb951..34195dda 100644 --- a/common/phal_L4/flash/flash.h +++ b/common/phal_L4/flash/flash.h @@ -19,8 +19,19 @@ #define FLASH_KEY_2 0xCDEF89AB // void PHAL_flashWriteU32(uint32_t* address, uint32_t value); +/** + * @brief Writes 64 bits to flash memory + * + * @param address Location to write + * @param data Data to write + */ void PHAL_flashWriteU64(uint32_t address, uint64_t data); -void PHAL_flashErasePage(uint8_t page); +/** + * @brief Erase a page in flash + * + * @param page Page to erase + */ +void PHAL_flashErasePage(uint8_t page); #endif \ No newline at end of file diff --git a/common/phal_L4/gpio/gpio.c b/common/phal_L4/gpio/gpio.c index 24ddc136..315ec593 100644 --- a/common/phal_L4/gpio/gpio.c +++ b/common/phal_L4/gpio/gpio.c @@ -1,7 +1,17 @@ +/** + * @file gpio.c + * @author Adam Busch (busch8@purdue.edu) + * @brief GPIO Driver for STM32L432 Devices + * @version 0.1 + * @date 2021-09-20 + * + * + * @copyright Copyright (c) 2021 + * + * + */ #include "common/phal_L4/gpio/gpio.h" - - bool PHAL_initGPIO(GPIOInitConfig_t config[], uint8_t config_len) { @@ -83,4 +93,4 @@ bool PHAL_initGPIO(GPIOInitConfig_t config[], uint8_t config_len) return false; } } -} \ No newline at end of file +} diff --git a/common/phal_L4/gpio/gpio.h b/common/phal_L4/gpio/gpio.h index 3b44bd8a..c785bb28 100644 --- a/common/phal_L4/gpio/gpio.h +++ b/common/phal_L4/gpio/gpio.h @@ -21,10 +21,10 @@ */ typedef enum { - GPIO_TYPE_INPUT = 0b00, /* Pin input mode */ - GPIO_TYPE_OUTPUT = 0b01, /* Pin output mode */ - GPIO_TYPE_AF = 0b10, /* Pin alternate function mode */ - GPIO_TYPE_ANALOG = 0b11, /* Pin alternate function mode */ + GPIO_TYPE_INPUT = 0b00, //!< Pin input mode + GPIO_TYPE_OUTPUT = 0b01, //!< Pin output mode + GPIO_TYPE_AF = 0b10, //!< Pin alternate function mode + GPIO_TYPE_ANALOG = 0b11, //!< Pin alternate function mode } GPIOPinType_t; /** @@ -32,10 +32,10 @@ typedef enum */ typedef enum { - GPIO_OUTPUT_LOW_SPEED = 0b00, /* Slew rate control, max 8Mhz */ - GPIO_OUTPUT_MED_SPEED = 0b01, /* Slew rate control, max 50Mhz */ - GPIO_OUTPUT_HIGH_SPEED = 0b10, /* Slew rate control, max 100Mhz */ - GPIO_OUTPUT_ULTRA_SPEED = 0b11, /* Slew rate control, max 180Mhz */ + GPIO_OUTPUT_LOW_SPEED = 0b00, //!< Slew rate control, max 8Mhz + GPIO_OUTPUT_MED_SPEED = 0b01, //!< Slew rate control, max 50Mhz + GPIO_OUTPUT_HIGH_SPEED = 0b10, //!< Slew rate control, max 100Mhz + GPIO_OUTPUT_ULTRA_SPEED = 0b11, //!< Slew rate control, max 180Mhz } GPIOOutputSpeed_t; /** @@ -43,8 +43,8 @@ typedef enum */ typedef enum { - GPIO_OUTPUT_PUSH_PULL = 0b0, /* Drive the output pin high and low */ - GPIO_OUTPUT_OPEN_DRAIN = 0b1, /* Drive the output pin low, high-z otherwise */ + GPIO_OUTPUT_PUSH_PULL = 0b0, //!< Drive the output pin high and low + GPIO_OUTPUT_OPEN_DRAIN = 0b1, //!< Drive the output pin low, high-z otherwise } GPIOOutputPull_t; /** @@ -52,9 +52,9 @@ typedef enum */ typedef enum { - GPIO_INPUT_OPEN_DRAIN = 0b00, /* No internal pull up/down */ - GPIO_INPUT_PULL_UP = 0b01, /* Weak internal pull-up enabled */ - GPIO_INPUT_PULL_DOWN = 0b10, /* Weak internal pull-down enabled */ + GPIO_INPUT_OPEN_DRAIN = 0b00, //!< No internal pull up/down + GPIO_INPUT_PULL_UP = 0b01, //!< Weak internal pull-up enabled + GPIO_INPUT_PULL_DOWN = 0b10, //!< Weak internal pull-down enabled } GPIOInputPull_t; /** @@ -62,21 +62,21 @@ typedef enum */ typedef struct { - GPIO_TypeDef *bank; /* GPIO Bank for configuration */ - uint8_t pin; /* Pin Number for configruation */ - GPIOPinType_t type; /* Output type of pin */ + GPIO_TypeDef *bank; //!< GPIO Bank for configuration + uint8_t pin; //!< Pin Number for configruation + GPIOPinType_t type; //!< Output type of pin struct { // INPUT ONLY FIELDS - GPIOInputPull_t pull; /* Push/Pull selection */ + GPIOInputPull_t pull; //!< Push/Pull selection // OUTPUT ONLY FIELDS - GPIOOutputSpeed_t ospeed; /* Output speed (slew rate) */ - GPIOOutputPull_t otype; /* Output push/pull */ + GPIOOutputSpeed_t ospeed; //!