mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-20 17:53:20 +00:00
fef16a8e7a
* Outdated apps: add api-light-usage * Gpio: update SD card CS pin settings * API-power: added fns to disable/enable external 3v3 dc-dc * API-gpio: separated SD card detect routines * Resources: removed sd cs pin * SD card: low level init now resets card power supply * App SD-filesystem: use new card detect fns * SD card: fix low level init headers * SD card: more realilable low level init, power reset, exit from command read cycle conditionally * App SD-filesystem: led notifiers, init cycling * SD card: backport to F4 * SD card: handle eject in init sequence * SD card: api to set level on detect gpio * SPI: api to set state on bus pins * SD card: set low state on bus pins while power reset Co-authored-by: coreglitch <mail@s3f.ru>
36 lines
890 B
C
36 lines
890 B
C
#include <api-hal-gpio.h>
|
|
#include <api-hal-spi.h>
|
|
#include <api-hal-resources.h>
|
|
#include <api-hal-delay.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);
|
|
}
|
|
|
|
void enable_cc1101_irq() {
|
|
HAL_NVIC_SetPriority(EXTI4_IRQn, 5, 0);
|
|
HAL_NVIC_EnableIRQ(EXTI4_IRQn);
|
|
}
|
|
|
|
extern COMP_HandleTypeDef hcomp1;
|
|
|
|
bool get_rfid_in_level() {
|
|
#ifdef INVERT_RFID_IN
|
|
return (HAL_COMP_GetOutputLevel(&hcomp1) == COMP_OUTPUT_LEVEL_LOW);
|
|
#else
|
|
return (HAL_COMP_GetOutputLevel(&hcomp1) == COMP_OUTPUT_LEVEL_HIGH);
|
|
#endif
|
|
}
|