mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-30 06:33:07 +00:00
f94633863c
* update fatfs integer types * fix sector size to 512 * fix sector size calculation * common fs api * fs api realization (sd card + fat fs) * better sector size definition * more api realization fns * add error description api, add common api * fix api flag naming, run app * add fs_info call * disable fatfs strfuncs, enable fatfs chmod * rework filesystem app * sd detect cycle, sd menu, sd eject feature * fix sd detect cycle * sd card format routine * ui improvements, sd info routine * properly unmount card * separate mode flags * add api folder, move app, rename app * fix api naming * update st-card-test to use api * update path to app * fixed potential problem of using sizeof union * updated api documentation, new time/date fns * update codeowners * changed app requirements * changed app order * sd insert/remove log
52 lines
1.2 KiB
C
52 lines
1.2 KiB
C
#include "api-hal-gpio.h"
|
|
#include "api-hal-resources.h"
|
|
#include "spi.h"
|
|
|
|
// init GPIO
|
|
void hal_gpio_init(
|
|
const GpioPin* gpio,
|
|
const GpioMode mode,
|
|
const GpioPull pull,
|
|
const GpioSpeed speed) {
|
|
// TODO: Alternate Functions
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
|
|
GPIO_InitStruct.Pin = gpio->pin;
|
|
GPIO_InitStruct.Mode = mode;
|
|
GPIO_InitStruct.Pull = pull;
|
|
GPIO_InitStruct.Speed = speed;
|
|
|
|
HAL_GPIO_Init(gpio->port, &GPIO_InitStruct);
|
|
}
|
|
|
|
bool hal_gpio_read_sd_detect(void) {
|
|
bool result = false;
|
|
|
|
// TODO open record
|
|
const GpioPin* sd_cs_record = &sd_cs_gpio;
|
|
|
|
// TODO: SPI manager
|
|
api_hal_spi_lock(&SPI_SD_HANDLE);
|
|
|
|
// configure pin as input
|
|
gpio_init_ex(sd_cs_record, GpioModeInput, GpioPullUp, GpioSpeedVeryHigh);
|
|
delay(1);
|
|
|
|
// if gpio_read == 0 return true else return false
|
|
result = !gpio_read(sd_cs_record);
|
|
|
|
// configure pin back
|
|
gpio_init_ex(sd_cs_record, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
|
|
gpio_write(sd_cs_record, 1);
|
|
delay(1);
|
|
|
|
// TODO: SPI manager
|
|
api_hal_spi_unlock(&SPI_SD_HANDLE);
|
|
|
|
return result;
|
|
}
|
|
|
|
void enable_cc1101_irq() {
|
|
HAL_NVIC_SetPriority(EXTI4_IRQn, 5, 0);
|
|
HAL_NVIC_EnableIRQ(EXTI4_IRQn);
|
|
}
|