Refactored function names to use camel case
This commit is contained in:
parent
99a8d562fa
commit
cdf605ede5
|
@ -94,7 +94,7 @@ void SerialUART::begin(const uint32_t baud) {
|
|||
}
|
||||
#endif
|
||||
|
||||
stm32_af_uart_init(instance, rxPort, rxPin, txPort, txPin);
|
||||
stm32AfUARTInit(instance, rxPort, rxPin, txPort, txPin);
|
||||
|
||||
handle->Init.BaudRate = baud;
|
||||
handle->Init.WordLength = UART_WORDLENGTH_8B;
|
||||
|
@ -141,12 +141,12 @@ size_t SerialUART::write(const uint8_t c) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
void SerialUART::stm32_set_rx(uint8_t rx) {
|
||||
void SerialUART::stm32SetRX(uint8_t rx) {
|
||||
rxPort = port_pin_list[rx].port;
|
||||
rxPin = port_pin_list[rx].pin_mask;
|
||||
}
|
||||
|
||||
void SerialUART::stm32_set_tx(uint8_t tx) {
|
||||
void SerialUART::stm32SetTX(uint8_t tx) {
|
||||
txPort = port_pin_list[tx].port;
|
||||
txPin = port_pin_list[tx].pin_mask;
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ class SerialUART : public Stream {
|
|||
using Print::write; // pull in write(str) and write(buf, size) from Print
|
||||
operator bool() { return true; }; // UART always active
|
||||
|
||||
void stm32_set_rx(uint8_t rx);
|
||||
void stm32_set_tx(uint8_t tx);
|
||||
void stm32SetRX(uint8_t rx);
|
||||
void stm32SetTX(uint8_t tx);
|
||||
|
||||
USART_TypeDef *instance = NULL;
|
||||
UART_HandleTypeDef *handle = NULL;
|
||||
|
|
|
@ -73,7 +73,7 @@ int analogRead(uint8_t pin) {
|
|||
}
|
||||
|
||||
ADC_ChannelConfTypeDef sConfig;
|
||||
sConfig.Channel = stm32_adc1_get_channel(port_pin_list[pin].port, port_pin_list[pin].pin_mask);
|
||||
sConfig.Channel = stm32ADC1GetChannel(port_pin_list[pin].port, port_pin_list[pin].pin_mask);
|
||||
sConfig.Rank = 1;
|
||||
|
||||
#if STM32L0
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "stm32l4xx.h"
|
||||
#include "stm32l4xx_hal.h"
|
||||
#else
|
||||
#error "STM32XX is not definedin boards.txt"
|
||||
#error "STM32XX is not defined in boards.txt"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include CHIP_PERIPHERAL_INCLUDE
|
||||
|
||||
GPIO_TypeDef *stm32_af_default(stm32_af_pin_list_type list[], int size, const void *instance, uint32_t *pin) {
|
||||
GPIO_TypeDef *stm32AfGetDefault(stm32_af_pin_list_type list[], int size, const void *instance, uint32_t *pin) {
|
||||
for(int i=0; i<size; i++) {
|
||||
if (instance == list[i].instance) {
|
||||
*pin = list[i].pin;
|
||||
|
@ -12,7 +12,7 @@ GPIO_TypeDef *stm32_af_default(stm32_af_pin_list_type list[], int size, const vo
|
|||
return NULL;
|
||||
}
|
||||
|
||||
uint32_t stm32_apb_clock_freq(void *instance) {
|
||||
uint32_t stm32GetClockFrequency(void *instance) {
|
||||
for(int i=0; i<sizeof(chip_clock_freq_list) / sizeof(chip_clock_freq_list[0]); i++) {
|
||||
if (chip_clock_freq_list[i].instance == instance) {
|
||||
return (chip_clock_freq_list[i].clock_freq_func)();
|
||||
|
@ -21,7 +21,7 @@ uint32_t stm32_apb_clock_freq(void *instance) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
uint8_t stm32_adc1_get_channel(GPIO_TypeDef *port, uint32_t pin_mask) {
|
||||
uint8_t stm32ADC1GetChannel(GPIO_TypeDef *port, uint32_t pin_mask) {
|
||||
for(int i=0; i<sizeof(chip_adc1_channel) / sizeof(chip_adc1_channel[0]); i++) {
|
||||
if (chip_adc1_channel[i].port == port && chip_adc1_channel[i].pin_mask == pin_mask) {
|
||||
return chip_adc1_channel[i].channel;
|
||||
|
@ -31,30 +31,30 @@ uint8_t stm32_adc1_get_channel(GPIO_TypeDef *port, uint32_t pin_mask) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
void stm32_af_uart_init(const USART_TypeDef *instance,
|
||||
void stm32AfUARTInit(const USART_TypeDef *instance,
|
||||
GPIO_TypeDef *rxPort, uint32_t rxPin,
|
||||
GPIO_TypeDef *txPort, uint32_t txPin) {
|
||||
|
||||
stm32_af_init(chip_af_usart_rx, sizeof(chip_af_usart_rx) / sizeof(chip_af_usart_rx[0]), instance, rxPort, rxPin, GPIO_MODE_AF_PP, GPIO_PULLUP);
|
||||
stm32_af_init(chip_af_usart_tx, sizeof(chip_af_usart_tx) / sizeof(chip_af_usart_tx[0]), instance, txPort, txPin, GPIO_MODE_AF_PP, GPIO_PULLUP);
|
||||
stm32AfInit(chip_af_usart_rx, sizeof(chip_af_usart_rx) / sizeof(chip_af_usart_rx[0]), instance, rxPort, rxPin, GPIO_MODE_AF_PP, GPIO_PULLUP);
|
||||
stm32AfInit(chip_af_usart_tx, sizeof(chip_af_usart_tx) / sizeof(chip_af_usart_tx[0]), instance, txPort, txPin, GPIO_MODE_AF_PP, GPIO_PULLUP);
|
||||
|
||||
}
|
||||
|
||||
void stm32_af_spi_init(const SPI_TypeDef *instance,
|
||||
void stm32AfSPIInit(const SPI_TypeDef *instance,
|
||||
GPIO_TypeDef *mosiPort, uint32_t mosiPin,
|
||||
GPIO_TypeDef *misoPort, uint32_t misoPin,
|
||||
GPIO_TypeDef *sckPort, uint32_t sckPin) {
|
||||
|
||||
stm32_af_init(chip_af_spi_mosi, sizeof(chip_af_spi_mosi) / sizeof(chip_af_spi_mosi[0]), instance, mosiPort, mosiPin, GPIO_MODE_AF_PP, GPIO_NOPULL);
|
||||
stm32_af_init(chip_af_spi_miso, sizeof(chip_af_spi_miso) / sizeof(chip_af_spi_miso[0]), instance, misoPort, misoPin, GPIO_MODE_AF_PP, GPIO_NOPULL);
|
||||
stm32_af_init(chip_af_spi_sck, sizeof(chip_af_spi_sck) / sizeof(chip_af_spi_sck[0]), instance, sckPort, sckPin, GPIO_MODE_AF_PP, GPIO_NOPULL);
|
||||
stm32AfInit(chip_af_spi_mosi, sizeof(chip_af_spi_mosi) / sizeof(chip_af_spi_mosi[0]), instance, mosiPort, mosiPin, GPIO_MODE_AF_PP, GPIO_NOPULL);
|
||||
stm32AfInit(chip_af_spi_miso, sizeof(chip_af_spi_miso) / sizeof(chip_af_spi_miso[0]), instance, misoPort, misoPin, GPIO_MODE_AF_PP, GPIO_NOPULL);
|
||||
stm32AfInit(chip_af_spi_sck, sizeof(chip_af_spi_sck) / sizeof(chip_af_spi_sck[0]), instance, sckPort, sckPin, GPIO_MODE_AF_PP, GPIO_NOPULL);
|
||||
|
||||
}
|
||||
|
||||
void stm32_af_i2c_init(const I2C_TypeDef *instance,
|
||||
void stm32AfI2CInit(const I2C_TypeDef *instance,
|
||||
GPIO_TypeDef *sdaPort, uint32_t sdaPin,
|
||||
GPIO_TypeDef *sclPort, uint32_t sclPin) {
|
||||
|
||||
stm32_af_init(chip_af_i2c_sda, sizeof(chip_af_i2c_sda) / sizeof(chip_af_i2c_sda[0]), instance, sdaPort, sdaPin, GPIO_MODE_AF_OD, GPIO_PULLUP);
|
||||
stm32_af_init(chip_af_i2c_scl, sizeof(chip_af_i2c_scl) / sizeof(chip_af_i2c_scl[0]), instance, sclPort, sclPin, GPIO_MODE_AF_OD, GPIO_PULLUP);
|
||||
stm32AfInit(chip_af_i2c_sda, sizeof(chip_af_i2c_sda) / sizeof(chip_af_i2c_sda[0]), instance, sdaPort, sdaPin, GPIO_MODE_AF_OD, GPIO_PULLUP);
|
||||
stm32AfInit(chip_af_i2c_scl, sizeof(chip_af_i2c_scl) / sizeof(chip_af_i2c_scl[0]), instance, sclPort, sclPin, GPIO_MODE_AF_OD, GPIO_PULLUP);
|
||||
}
|
||||
|
|
|
@ -42,38 +42,38 @@ typedef struct {
|
|||
extern "C"{
|
||||
#endif
|
||||
|
||||
void stm32_af_uart_init(const USART_TypeDef *instance,
|
||||
void stm32AfUARTInit(const USART_TypeDef *instance,
|
||||
GPIO_TypeDef *rxPort, uint32_t rxPin,
|
||||
GPIO_TypeDef *txPort, uint32_t txPin);
|
||||
|
||||
void stm32_af_spi_init(const SPI_TypeDef *instance,
|
||||
void stm32AfSPIInit(const SPI_TypeDef *instance,
|
||||
GPIO_TypeDef *mosiPort, uint32_t mosiPin,
|
||||
GPIO_TypeDef *misoPort, uint32_t misoPin,
|
||||
GPIO_TypeDef *sckPort, uint32_t sckPin);
|
||||
|
||||
void stm32_af_i2c_init(const I2C_TypeDef *instance,
|
||||
void stm32AfI2CInit(const I2C_TypeDef *instance,
|
||||
GPIO_TypeDef *sdaPort, uint32_t sdaPin,
|
||||
GPIO_TypeDef *sclPort, uint32_t sclPin);
|
||||
|
||||
/**
|
||||
* Get the clock frequency associated with the peripheral instance
|
||||
*/
|
||||
uint32_t stm32_apb_clock_freq(void *instance);
|
||||
uint32_t stm32GetClockFrequency(void *instance);
|
||||
|
||||
/**
|
||||
* Get the ADC1 channel for the specified port / pin
|
||||
*/
|
||||
uint8_t stm32_adc1_get_channel(GPIO_TypeDef *port, uint32_t pin_mask);
|
||||
uint8_t stm32ADC1GetChannel(GPIO_TypeDef *port, uint32_t pin_mask);
|
||||
|
||||
/**
|
||||
* Internal: set the AF function for the selected peripheral on the selected pin
|
||||
*/
|
||||
void stm32_af_init(const stm32_af_pin_list_type list[], int size, const void *instance, GPIO_TypeDef *port, uint32_t pin, uint32_t mode, uint32_t pull);
|
||||
void stm32AfInit(const stm32_af_pin_list_type list[], int size, const void *instance, GPIO_TypeDef *port, uint32_t pin, uint32_t mode, uint32_t pull);
|
||||
|
||||
/**
|
||||
* Internal: get the default pin for the given peripheral
|
||||
*/
|
||||
GPIO_TypeDef *stm32_af_default(stm32_af_pin_list_type list[], int size, const void *instance, uint32_t *pin);
|
||||
GPIO_TypeDef *stm32AfGetDefault(stm32_af_pin_list_type list[], int size, const void *instance, uint32_t *pin);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "stm32_gpio_af.h"
|
||||
|
||||
int8_t stm32_af_get(const stm32_af_pin_list_type list[], int size, const void *instance, const GPIO_TypeDef *port, const uint32_t pin) {
|
||||
int8_t stm32AfGet(const stm32_af_pin_list_type list[], int size, const void *instance, const GPIO_TypeDef *port, const uint32_t pin) {
|
||||
for(int i=0; i<size; i++) {
|
||||
if (instance == list[i].instance
|
||||
&& port == list[i].port
|
||||
|
@ -15,12 +15,12 @@ int8_t stm32_af_get(const stm32_af_pin_list_type list[], int size, const void *i
|
|||
return 0;
|
||||
}
|
||||
|
||||
void stm32_af_init(const stm32_af_pin_list_type list[], int size, const void *instance, GPIO_TypeDef *port, uint32_t pin, uint32_t mode, uint32_t pull) {
|
||||
void stm32AfInit(const stm32_af_pin_list_type list[], int size, const void *instance, GPIO_TypeDef *port, uint32_t pin, uint32_t mode, uint32_t pull) {
|
||||
if (stm32_pwm_disable_callback != NULL) {
|
||||
(*stm32_pwm_disable_callback)(port, pin);
|
||||
}
|
||||
if (port == NULL) {
|
||||
port = stm32_af_default(list, size, instance, &pin);
|
||||
port = stm32AfGetDefault(list, size, instance, &pin);
|
||||
}
|
||||
stm32_gpio_clock(port);
|
||||
|
||||
|
@ -29,7 +29,7 @@ void stm32_af_init(const stm32_af_pin_list_type list[], int size, const void *in
|
|||
GPIO_InitStruct.Mode = mode;
|
||||
GPIO_InitStruct.Pull = pull;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.Alternate = stm32_af_get(list, size, instance, port, pin);
|
||||
GPIO_InitStruct.Alternate = stm32AfGet(list, size, instance, port, pin);
|
||||
HAL_GPIO_Init(port, &GPIO_InitStruct);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "stm32_gpio_af.h"
|
||||
|
||||
stm32_af_callback stm32_af_get(const stm32_af_pin_list_type list[], int size, const void *instance, const GPIO_TypeDef *port, const uint32_t pin) {
|
||||
stm32_af_callback stm32AfGet(const stm32_af_pin_list_type list[], int size, const void *instance, const GPIO_TypeDef *port, const uint32_t pin) {
|
||||
for(int i=0; i<size; i++) {
|
||||
if (instance == list[i].instance
|
||||
&& port == list[i].port
|
||||
|
@ -14,12 +14,12 @@ stm32_af_callback stm32_af_get(const stm32_af_pin_list_type list[], int size, co
|
|||
return 0;
|
||||
}
|
||||
|
||||
void stm32_af_init(const stm32_af_pin_list_type list[], int size, const void *instance, GPIO_TypeDef *port, uint32_t pin, uint32_t mode, uint32_t pull) {
|
||||
void stm32AfInit(const stm32_af_pin_list_type list[], int size, const void *instance, GPIO_TypeDef *port, uint32_t pin, uint32_t mode, uint32_t pull) {
|
||||
if (stm32_pwm_disable_callback != NULL) {
|
||||
(*stm32_pwm_disable_callback)(port, pin);
|
||||
}
|
||||
if (port == NULL) {
|
||||
port = stm32_af_default(list, size, instance, &pin);
|
||||
port = stm32AfDefault(list, size, instance, &pin);
|
||||
}
|
||||
stm32_gpio_clock(port);
|
||||
|
||||
|
@ -30,7 +30,7 @@ void stm32_af_init(const stm32_af_pin_list_type list[], int size, const void *in
|
|||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
HAL_GPIO_Init(port, &GPIO_InitStruct);
|
||||
|
||||
stm32_af_get(list, size, instance, port, pin)();
|
||||
stm32AfGet(list, size, instance, port, pin)();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
SPIFlash flash(PB0);
|
||||
|
||||
void setup() {
|
||||
SPI.stm32_set_mosi(PB5);
|
||||
SPI.stm32_set_miso(PB4);
|
||||
SPI.stm32_set_sck(PB3);
|
||||
SPI.stm32SetMOSI(PB5);
|
||||
SPI.stm32SetMISO(PB4);
|
||||
SPI.stm32SetSCK(PB3);
|
||||
|
||||
Serial.begin(115200);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
void SPIClass::begin() {
|
||||
apb_freq = stm32_apb_clock_freq((void*)spiHandle.Instance);
|
||||
apb_freq = stm32GetClockFrequency((void*)spiHandle.Instance);
|
||||
|
||||
spiHandle.Init.Mode = SPI_MODE_MASTER;
|
||||
spiHandle.Init.Direction = SPI_DIRECTION_2LINES;
|
||||
|
@ -36,7 +36,7 @@ void SPIClass::begin() {
|
|||
if (spiHandle.Instance == SPI6) __HAL_RCC_SPI6_CLK_ENABLE();
|
||||
#endif
|
||||
|
||||
stm32_af_spi_init(spiHandle.Instance, mosiPort, mosiPin, misoPort, misoPin, sckPort, sckPin);
|
||||
stm32AfSPIInit(spiHandle.Instance, mosiPort, mosiPin, misoPort, misoPin, sckPort, sckPin);
|
||||
};
|
||||
|
||||
void SPIClass::beginTransaction(SPISettings settings) {
|
||||
|
@ -104,17 +104,17 @@ void SPIClass::setClockDivider(uint8_t clockDevider) {
|
|||
beginTransaction(SPISettings(apb_freq / clockDevider, settings.bitOrder, settings.dataMode));
|
||||
}
|
||||
|
||||
void SPIClass::stm32_set_mosi(uint8_t mosi) {
|
||||
void SPIClass::stm32SetMOSI(uint8_t mosi) {
|
||||
mosiPort = port_pin_list[mosi].port;
|
||||
mosiPin = port_pin_list[mosi].pin_mask;
|
||||
}
|
||||
|
||||
void SPIClass::stm32_set_miso(uint8_t miso) {
|
||||
void SPIClass::stm32SetMISO(uint8_t miso) {
|
||||
misoPort = port_pin_list[miso].port;
|
||||
misoPin = port_pin_list[miso].pin_mask;
|
||||
}
|
||||
|
||||
void SPIClass::stm32_set_sck(uint8_t sck) {
|
||||
void SPIClass::stm32SetSCK(uint8_t sck) {
|
||||
sckPort = port_pin_list[sck].port;
|
||||
sckPin = port_pin_list[sck].pin_mask;
|
||||
}
|
||||
|
|
|
@ -59,14 +59,14 @@ class SPIClass {
|
|||
SPIClass(SPI_TypeDef *instance, uint8_t mosi, uint8_t miso, uint8_t sck) {
|
||||
spiHandle.Instance = instance;
|
||||
|
||||
stm32_set_mosi(mosi);
|
||||
stm32_set_miso(miso);
|
||||
stm32_set_sck(sck);
|
||||
stm32SetMOSI(mosi);
|
||||
stm32SetMISO(miso);
|
||||
stm32SetSCK(sck);
|
||||
};
|
||||
|
||||
void stm32_set_mosi(uint8_t mosi);
|
||||
void stm32_set_miso(uint8_t miso);
|
||||
void stm32_set_sck(uint8_t sck);
|
||||
void stm32SetMOSI(uint8_t mosi);
|
||||
void stm32SetMISO(uint8_t miso);
|
||||
void stm32SetSCK(uint8_t sck);
|
||||
|
||||
void begin();
|
||||
void end();
|
||||
|
|
|
@ -15,7 +15,7 @@ void TwoWire::begin(void) {
|
|||
|
||||
isMaster = 1;
|
||||
|
||||
stm32_af_i2c_init(handle.Instance, sdaPort, sdaPin, sclPort, sclPin);
|
||||
stm32AfI2CInit(handle.Instance, sdaPort, sdaPin, sclPort, sclPin);
|
||||
|
||||
__HAL_RCC_I2C1_CLK_ENABLE();
|
||||
|
||||
|
@ -302,12 +302,12 @@ void TwoWire::flush(void) {
|
|||
|
||||
}
|
||||
|
||||
void TwoWire::stm32_set_sda(uint8_t sda) {
|
||||
void TwoWire::stm32SetSDA(uint8_t sda) {
|
||||
sdaPort = port_pin_list[sda].port;
|
||||
sdaPin = port_pin_list[sda].pin_mask;
|
||||
}
|
||||
|
||||
void TwoWire::stm32_set_scl(uint8_t scl) {
|
||||
void TwoWire::stm32SetSCL(uint8_t scl) {
|
||||
sclPort = port_pin_list[scl].port;
|
||||
sclPin = port_pin_list[scl].pin_mask;
|
||||
}
|
||||
|
|
|
@ -82,8 +82,8 @@ class TwoWire : public Stream {
|
|||
void onReceive( void (*)(int) );
|
||||
void onRequest( void (*)(void) );
|
||||
|
||||
void stm32_set_sda(uint8_t sda);
|
||||
void stm32_set_scl(uint8_t scl);
|
||||
void stm32SetSDA(uint8_t sda);
|
||||
void stm32SetSCL(uint8_t scl);
|
||||
|
||||
inline size_t write(unsigned long n) { return write((uint8_t)n); }
|
||||
inline size_t write(long n) { return write((uint8_t)n); }
|
||||
|
|
|
@ -17,12 +17,12 @@ TODO: IMPLEMENT You can set what is Serial from the boards menu. By default, it
|
|||
Please refer to the [official documentation](https://www.arduino.cc/en/reference/serial) for
|
||||
the description of Serial functions.
|
||||
|
||||
#### **`SerialUARTx.stm32_set_rx(uint8_t pin)`**
|
||||
#### **`SerialUARTx.stm32SetRX(uint8_t pin)`**
|
||||
|
||||
Set the RX signal to the specified pin. Please check the chip documentation for which pin can be used for RX.
|
||||
This must be called before begin()!
|
||||
|
||||
#### **`SerialUARTx.stm32_set_tx(uint8_t pin)`**
|
||||
#### **`SerialUARTx.stm32SetTx(uint8_t pin)`**
|
||||
|
||||
Set the TX signal to the specified pin. Please check the chip documentation for which pin can be used for TX.
|
||||
This must be called before begin()!
|
||||
|
@ -67,7 +67,7 @@ To avoid confusion, it is better to use the constructor below with implicit pins
|
|||
Create a SPI object that is connected to the instance, on the specified mosi/miso/sck pins.
|
||||
|
||||
> Example: set up SPI2
|
||||
`SPIClass SPI_2(SPI2, Pmosi, Piso, Psck);`
|
||||
`SPIClass SPI_2(SPI2, mosi, iso, sck);`
|
||||
|
||||
#### **`SPI.begin()`**
|
||||
|
||||
|
@ -105,22 +105,22 @@ TODO not yet implemented
|
|||
|
||||
TODO write doc
|
||||
|
||||
#### **`SPI.stm32_set_mosi(uint8_t pin);`**
|
||||
#### **`SPI.stm32SetMOSI(uint8_t pin);`**
|
||||
|
||||
TODO write doc
|
||||
This method must be called before begin()!
|
||||
|
||||
#### **`SPI.stm32_set_miso(uint8_t pin);`**
|
||||
#### **`SPI.stm32SetMISO(uint8_t pin);`**
|
||||
|
||||
TODO write doc
|
||||
This method must be called before begin()!
|
||||
|
||||
#### **`SPI.stm32_set_sck(uint8_t pin);`**
|
||||
#### **`SPI.stm32SetSCK(uint8_t pin);`**
|
||||
|
||||
TODO write doc
|
||||
This method must be called before begin()!
|
||||
|
||||
#### **`SPI.stm32_set_instance(...);`**
|
||||
#### **`SPI.stm32SetInstance(...);`**
|
||||
|
||||
TODO implement
|
||||
This method must be called before begin()!
|
||||
|
|
Loading…
Reference in New Issue