Rename api-hal to furi-hal (#629)
This commit is contained in:
34
firmware/targets/furi-hal-include/furi-hal-boot.h
Normal file
34
firmware/targets/furi-hal-include/furi-hal-boot.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Boot modes */
|
||||
typedef enum {
|
||||
FuriHalBootModeNormal,
|
||||
FuriHalBootModeDFU
|
||||
} FuriHalBootMode;
|
||||
|
||||
/** Boot flags */
|
||||
typedef enum {
|
||||
FuriHalBootFlagDefault=0,
|
||||
FuriHalBootFlagFactoryReset=1,
|
||||
} FuriHalBootFlag;
|
||||
|
||||
/** Initialize boot subsystem */
|
||||
void furi_hal_boot_init();
|
||||
|
||||
/** Set boot mode */
|
||||
void furi_hal_boot_set_mode(FuriHalBootMode mode);
|
||||
|
||||
/** Set boot flags */
|
||||
void furi_hal_boot_set_flags(FuriHalBootFlag flags);
|
||||
|
||||
/** Get boot flag */
|
||||
FuriHalBootFlag furi_hal_boot_get_flags();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
60
firmware/targets/furi-hal-include/furi-hal-bt.h
Normal file
60
firmware/targets/furi-hal-include/furi-hal-bt.h
Normal file
@@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include <m-string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Initialize */
|
||||
void furi_hal_bt_init();
|
||||
|
||||
/** Start BLE app */
|
||||
bool furi_hal_bt_start_app();
|
||||
|
||||
/** Get BT/BLE system component state */
|
||||
void furi_hal_bt_dump_state(string_t buffer);
|
||||
|
||||
/** Get BT/BLE system component state */
|
||||
bool furi_hal_bt_is_alive();
|
||||
|
||||
/**
|
||||
* Lock shared access to flash controller
|
||||
* @return true if lock was successful, false if not
|
||||
*/
|
||||
bool furi_hal_bt_lock_flash();
|
||||
|
||||
/** Unlock shared access to flash controller */
|
||||
void furi_hal_bt_unlock_flash();
|
||||
|
||||
/** Start ble tone tx at given channel and power */
|
||||
void furi_hal_bt_start_tone_tx(uint8_t channel, uint8_t power);
|
||||
|
||||
/** Stop ble tone tx */
|
||||
void furi_hal_bt_stop_tone_tx();
|
||||
|
||||
/** Start sending ble packets at a given frequency and datarate */
|
||||
void furi_hal_bt_start_packet_tx(uint8_t channel, uint8_t pattern, uint8_t datarate);
|
||||
|
||||
/** Stop sending ble packets */
|
||||
uint16_t furi_hal_bt_stop_packet_test();
|
||||
|
||||
/** Start receiving packets */
|
||||
void furi_hal_bt_start_packet_rx(uint8_t channel, uint8_t datarate);
|
||||
|
||||
/** Set up the RF to listen to a given RF channel */
|
||||
void furi_hal_bt_start_rx(uint8_t channel);
|
||||
|
||||
/** Stop RF listenning */
|
||||
void furi_hal_bt_stop_rx();
|
||||
|
||||
/** Get RSSI */
|
||||
float furi_hal_bt_get_rssi();
|
||||
|
||||
/** Get number of transmitted packets */
|
||||
uint32_t furi_hal_bt_get_transmitted_packets();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
22
firmware/targets/furi-hal-include/furi-hal-delay.h
Normal file
22
firmware/targets/furi-hal-include/furi-hal-delay.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "main.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Init DWT */
|
||||
void furi_hal_delay_init(void);
|
||||
|
||||
/**
|
||||
* Delay in milliseconds
|
||||
* @warning Cannot be used from ISR
|
||||
*/
|
||||
void delay(float milliseconds);
|
||||
|
||||
/** Delay in microseconds */
|
||||
void delay_us(float microseconds);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
87
firmware/targets/furi-hal-include/furi-hal-i2c.h
Normal file
87
firmware/targets/furi-hal-include/furi-hal-i2c.h
Normal file
@@ -0,0 +1,87 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <furi-hal-resources.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Init I2C */
|
||||
void furi_hal_i2c_init();
|
||||
|
||||
/**
|
||||
* Perform I2C tx transfer
|
||||
* @param instance I2C_TypeDef instance
|
||||
* @param address I2C slave address
|
||||
* @param data pointer to data buffer
|
||||
* @param size size of data buffer
|
||||
* @param timeout timeout in CPU ticks
|
||||
* @return true on successful transfer, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_tx(
|
||||
I2C_TypeDef* instance,
|
||||
const uint8_t address,
|
||||
const uint8_t* data,
|
||||
const uint8_t size,
|
||||
uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Perform I2C rx transfer
|
||||
* @param instance I2C_TypeDef instance
|
||||
* @param address I2C slave address
|
||||
* @param data pointer to data buffer
|
||||
* @param size size of data buffer
|
||||
* @param timeout timeout in CPU ticks
|
||||
* @return true on successful transfer, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_rx(
|
||||
I2C_TypeDef* instance,
|
||||
const uint8_t address,
|
||||
uint8_t* data,
|
||||
const uint8_t size,
|
||||
uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Perform I2C tx and rx transfers
|
||||
* @param instance I2C_TypeDef instance
|
||||
* @param address I2C slave address
|
||||
* @param tx_data pointer to tx data buffer
|
||||
* @param tx_size size of tx data buffer
|
||||
* @param rx_data pointer to rx data buffer
|
||||
* @param rx_size size of rx data buffer
|
||||
* @param timeout timeout in CPU ticks
|
||||
* @return true on successful transfer, false otherwise
|
||||
*/
|
||||
bool furi_hal_i2c_trx(
|
||||
I2C_TypeDef* instance,
|
||||
const uint8_t address,
|
||||
const uint8_t* tx_data,
|
||||
const uint8_t tx_size,
|
||||
uint8_t* rx_data,
|
||||
const uint8_t rx_size,
|
||||
uint32_t timeout);
|
||||
|
||||
/** Acquire I2C mutex */
|
||||
void furi_hal_i2c_lock();
|
||||
|
||||
/** Release I2C mutex */
|
||||
void furi_hal_i2c_unlock();
|
||||
|
||||
/**
|
||||
* With clause for I2C peripheral
|
||||
* @param type type of function_body
|
||||
* @param pointer pointer to return of function_body
|
||||
* @param function_body a (){} lambda declaration, executed with I2C mutex acquired
|
||||
*/
|
||||
#define with_furi_hal_i2c(type, pointer, function_body) \
|
||||
{ \
|
||||
furi_hal_i2c_lock(); \
|
||||
*pointer = ({ type __fn__ function_body __fn__; })(); \
|
||||
furi_hal_i2c_unlock(); \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
20
firmware/targets/furi-hal-include/furi-hal-ibutton.h
Normal file
20
firmware/targets/furi-hal-include/furi-hal-ibutton.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void furi_hal_ibutton_start();
|
||||
|
||||
void furi_hal_ibutton_stop();
|
||||
|
||||
void furi_hal_ibutton_pin_low();
|
||||
|
||||
void furi_hal_ibutton_pin_high();
|
||||
|
||||
bool furi_hal_ibutton_pin_get_level();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
121
firmware/targets/furi-hal-include/furi-hal-irda.h
Normal file
121
firmware/targets/furi-hal-include/furi-hal-irda.h
Normal file
@@ -0,0 +1,121 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
FuriHalIrdaTxGetDataStateError, /* An error occured during transmission */
|
||||
FuriHalIrdaTxGetDataStateOk, /* New data obtained */
|
||||
FuriHalIrdaTxGetDataStateDone, /* New data obtained, and this is end of package */
|
||||
FuriHalIrdaTxGetDataStateLastDone, /* New data obtained, and this is end of package and no more data available */
|
||||
} FuriHalIrdaTxGetDataState;
|
||||
|
||||
typedef FuriHalIrdaTxGetDataState (*FuriHalIrdaTxGetDataCallback) (void* context, uint32_t* duration, bool* level);
|
||||
|
||||
/**
|
||||
* Signature of callback function for receiving continuous IRDA rx signal.
|
||||
*
|
||||
* @param ctx[in] - context to pass to callback
|
||||
* @param level[in] - level of input IRDA rx signal
|
||||
* @param duration[in] - duration of continuous rx signal level in us
|
||||
*/
|
||||
typedef void (*FuriHalIrdaRxCaptureCallback)(void* ctx, bool level, uint32_t duration);
|
||||
|
||||
/**
|
||||
* Signature of callback function for reaching silence timeout on IRDA port.
|
||||
*
|
||||
* @param ctx[in] - context to pass to callback
|
||||
*/
|
||||
typedef void (*FuriHalIrdaRxTimeoutCallback)(void* ctx);
|
||||
|
||||
/**
|
||||
* Initialize IRDA RX timer to receive interrupts.
|
||||
* It provides interrupts for every RX-signal edge changing
|
||||
* with its duration.
|
||||
*/
|
||||
void furi_hal_irda_async_rx_start(void);
|
||||
|
||||
/**
|
||||
* Deinitialize IRDA RX interrupt.
|
||||
*/
|
||||
void furi_hal_irda_async_rx_stop(void);
|
||||
|
||||
/** Setup api hal for receiving silence timeout.
|
||||
* Should be used with 'furi_hal_irda_timeout_irq_set_callback()'.
|
||||
*
|
||||
* @param[in] timeout_ms - time to wait for silence on IRDA port
|
||||
* before generating IRQ.
|
||||
*/
|
||||
void furi_hal_irda_async_rx_set_timeout(uint32_t timeout_ms);
|
||||
|
||||
/**
|
||||
* Setup callback for previously initialized IRDA RX interrupt.
|
||||
*
|
||||
* @param[in] callback - callback to call when RX signal edge changing occurs
|
||||
* @param[in] ctx - context for callback
|
||||
*/
|
||||
void furi_hal_irda_async_rx_set_capture_isr_callback(FuriHalIrdaRxCaptureCallback callback, void *ctx);
|
||||
|
||||
/**
|
||||
* Setup callback for reaching silence timeout on IRDA port.
|
||||
* Should setup api hal with 'furi_hal_irda_setup_rx_timeout_irq()' first.
|
||||
*
|
||||
* @param[in] callback - callback for silence timeout
|
||||
* @param[in] ctx - context to pass to callback
|
||||
*/
|
||||
void furi_hal_irda_async_rx_set_timeout_isr_callback(FuriHalIrdaRxTimeoutCallback callback, void *ctx);
|
||||
|
||||
/**
|
||||
* Check if IRDA is in use now.
|
||||
* @return true - IRDA is busy, false otherwise.
|
||||
*/
|
||||
bool furi_hal_irda_is_busy(void);
|
||||
|
||||
/**
|
||||
* Set callback providing new data. This function has to be called
|
||||
* before furi_hal_irda_async_tx_start().
|
||||
*
|
||||
* @param[in] callback - function to provide new data
|
||||
* @param[in] context - context for callback
|
||||
*/
|
||||
void furi_hal_irda_async_tx_set_data_isr_callback(FuriHalIrdaTxGetDataCallback callback, void* context);
|
||||
|
||||
/**
|
||||
* Start IR asynchronous transmission. It can be stopped by 2 reasons:
|
||||
* 1) implicit call for furi_hal_irda_async_tx_stop()
|
||||
* 2) callback can provide FuriHalIrdaTxGetDataStateLastDone response
|
||||
* which means no more data available for transmission.
|
||||
*
|
||||
* Any func (furi_hal_irda_async_tx_stop() or
|
||||
* furi_hal_irda_async_tx_wait_termination()) has to be called to wait
|
||||
* end of transmission and free resources.
|
||||
*
|
||||
* @param[in] freq - frequency for PWM
|
||||
* @param[in] duty_cycle - duty cycle for PWM
|
||||
* @return true if transmission successfully started, false otherwise.
|
||||
* If start failed no need to free resources.
|
||||
*/
|
||||
bool furi_hal_irda_async_tx_start(uint32_t freq, float duty_cycle);
|
||||
|
||||
/**
|
||||
* Stop IR asynchronous transmission and free resources.
|
||||
* Transmission will stop as soon as transmission reaches end of
|
||||
* package (FuriHalIrdaTxGetDataStateDone or FuriHalIrdaTxGetDataStateLastDone).
|
||||
*/
|
||||
void furi_hal_irda_async_tx_stop(void);
|
||||
|
||||
/**
|
||||
* Wait for end of IR asynchronous transmission and free resources.
|
||||
* Transmission will stop as soon as transmission reaches end of
|
||||
* transmission (FuriHalIrdaTxGetDataStateLastDone).
|
||||
*/
|
||||
void furi_hal_irda_async_tx_wait_termination(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
23
firmware/targets/furi-hal-include/furi-hal-light.h
Normal file
23
firmware/targets/furi-hal-include/furi-hal-light.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <furi-hal-resources.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Init light driver */
|
||||
void furi_hal_light_init();
|
||||
|
||||
/**
|
||||
* Set light value
|
||||
* @param light - Light
|
||||
* @param value - light brightness [0-255]
|
||||
*/
|
||||
void furi_hal_light_set(Light light, uint8_t value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
66
firmware/targets/furi-hal-include/furi-hal-nfc.h
Normal file
66
firmware/targets/furi-hal-include/furi-hal-nfc.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include <rfal_nfc.h>
|
||||
#include <st_errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FURI_HAL_NFC_UID_MAX_LEN 10
|
||||
|
||||
/**
|
||||
* Init nfc
|
||||
*/
|
||||
void furi_hal_nfc_init();
|
||||
|
||||
/**
|
||||
* Check if nfc worker is busy
|
||||
*/
|
||||
bool furi_hal_nfc_is_busy();
|
||||
|
||||
/**
|
||||
* NFC field on
|
||||
*/
|
||||
void furi_hal_nfc_field_on();
|
||||
|
||||
/**
|
||||
* NFC field off
|
||||
*/
|
||||
void furi_hal_nfc_field_off();
|
||||
|
||||
/**
|
||||
* NFC start sleep
|
||||
*/
|
||||
void furi_hal_nfc_start_sleep();
|
||||
|
||||
/**
|
||||
* NFC stop sleep
|
||||
*/
|
||||
void furi_hal_nfc_exit_sleep();
|
||||
|
||||
/**
|
||||
* NFC poll
|
||||
*/
|
||||
bool furi_hal_nfc_detect(rfalNfcDevice** dev_list, uint8_t* dev_cnt, uint32_t timeout, bool deactivate);
|
||||
|
||||
/**
|
||||
* NFC listen
|
||||
*/
|
||||
bool furi_hal_nfc_listen(uint8_t* uid, uint8_t uid_len, uint8_t* atqa, uint8_t sak, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* NFC data exchange
|
||||
*/
|
||||
ReturnCode furi_hal_nfc_data_exchange(uint8_t* tx_buff, uint16_t tx_len, uint8_t** rx_buff, uint16_t** rx_len, bool deactivate);
|
||||
|
||||
/**
|
||||
* NFC deactivate and start sleep
|
||||
*/
|
||||
void furi_hal_nfc_deactivate();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
104
firmware/targets/furi-hal-include/furi-hal-power.h
Normal file
104
firmware/targets/furi-hal-include/furi-hal-power.h
Normal file
@@ -0,0 +1,104 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <m-string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Power IC type */
|
||||
typedef enum {
|
||||
FuriHalPowerICCharger,
|
||||
FuriHalPowerICFuelGauge,
|
||||
} FuriHalPowerIC;
|
||||
|
||||
/** Initialize drivers */
|
||||
void furi_hal_power_init();
|
||||
|
||||
/**
|
||||
* Get current insomnia level
|
||||
* @return insomnia level: 0 - no insomnia, >0 - insomnia, bearer count.
|
||||
*/
|
||||
uint16_t furi_hal_power_insomnia_level();
|
||||
|
||||
/**
|
||||
* Enter insomnia mode
|
||||
* Prevents device from going to sleep
|
||||
* @warning Internally increases insomnia level
|
||||
* Must be paired with furi_hal_power_insomnia_exit
|
||||
*/
|
||||
void furi_hal_power_insomnia_enter();
|
||||
|
||||
/**
|
||||
* Exit insomnia mode
|
||||
* Allow device to go to sleep
|
||||
* @warning Internally decreases insomnia level.
|
||||
* Must be paired with furi_hal_power_insomnia_enter
|
||||
*/
|
||||
void furi_hal_power_insomnia_exit();
|
||||
|
||||
/** Check if sleep availble */
|
||||
bool furi_hal_power_sleep_available();
|
||||
|
||||
/** Check if deep sleep availble */
|
||||
bool furi_hal_power_deep_sleep_available();
|
||||
|
||||
/** Go to sleep */
|
||||
void furi_hal_power_sleep();
|
||||
|
||||
/** Get predicted remaining battery capacity in percents */
|
||||
uint8_t furi_hal_power_get_pct();
|
||||
|
||||
/** Get battery health state in percents */
|
||||
uint8_t furi_hal_power_get_bat_health_pct();
|
||||
|
||||
/** Get charging status */
|
||||
bool furi_hal_power_is_charging();
|
||||
|
||||
/** Poweroff device */
|
||||
void furi_hal_power_off();
|
||||
|
||||
/** Reset device */
|
||||
void furi_hal_power_reset();
|
||||
|
||||
/** OTG enable */
|
||||
void furi_hal_power_enable_otg();
|
||||
|
||||
/** OTG disable */
|
||||
void furi_hal_power_disable_otg();
|
||||
|
||||
/** Get remaining battery battery capacity in mAh */
|
||||
uint32_t furi_hal_power_get_battery_remaining_capacity();
|
||||
|
||||
/** Get full charge battery capacity in mAh */
|
||||
uint32_t furi_hal_power_get_battery_full_capacity();
|
||||
|
||||
/** Get battery voltage in V */
|
||||
float furi_hal_power_get_battery_voltage(FuriHalPowerIC ic);
|
||||
|
||||
/** Get battery current in A */
|
||||
float furi_hal_power_get_battery_current(FuriHalPowerIC ic);
|
||||
|
||||
/** Get temperature in C */
|
||||
float furi_hal_power_get_battery_temperature(FuriHalPowerIC ic);
|
||||
|
||||
/** Get System voltage in V */
|
||||
float furi_hal_power_get_system_voltage();
|
||||
|
||||
/** Get USB voltage in V */
|
||||
float furi_hal_power_get_usb_voltage();
|
||||
|
||||
/** Get power system component state */
|
||||
void furi_hal_power_dump_state();
|
||||
|
||||
/** Enable 3.3v on external gpio and sd card */
|
||||
void furi_hal_power_enable_external_3_3v();
|
||||
|
||||
/** Disable 3.3v on external gpio and sd card */
|
||||
void furi_hal_power_disable_external_3_3v();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
117
firmware/targets/furi-hal-include/furi-hal-rfid.h
Normal file
117
firmware/targets/furi-hal-include/furi-hal-rfid.h
Normal file
@@ -0,0 +1,117 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <main.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief config rfid pins to reset state
|
||||
*
|
||||
*/
|
||||
void furi_hal_rfid_pins_reset();
|
||||
|
||||
/**
|
||||
* @brief config rfid pins to emulate state
|
||||
*
|
||||
*/
|
||||
void furi_hal_rfid_pins_emulate();
|
||||
|
||||
/**
|
||||
* @brief config rfid pins to read state
|
||||
*
|
||||
*/
|
||||
void furi_hal_rfid_pins_read();
|
||||
|
||||
/**
|
||||
* @brief config rfid timer to read state
|
||||
*
|
||||
* @param freq timer frequency
|
||||
* @param duty_cycle timer duty cycle, 0.0-1.0
|
||||
*/
|
||||
void furi_hal_rfid_tim_read(float freq, float duty_cycle);
|
||||
|
||||
/**
|
||||
* @brief start read timer
|
||||
*
|
||||
*/
|
||||
void furi_hal_rfid_tim_read_start();
|
||||
|
||||
/**
|
||||
* @brief stop read timer
|
||||
*
|
||||
*/
|
||||
void furi_hal_rfid_tim_read_stop();
|
||||
|
||||
/**
|
||||
* @brief config rfid timer to emulate state
|
||||
*
|
||||
* @param freq timer frequency
|
||||
*/
|
||||
void furi_hal_rfid_tim_emulate(float freq);
|
||||
|
||||
/**
|
||||
* @brief start emulation timer
|
||||
*
|
||||
*/
|
||||
void furi_hal_rfid_tim_emulate_start();
|
||||
|
||||
/**
|
||||
* @brief stop emulation timer
|
||||
*
|
||||
*/
|
||||
void furi_hal_rfid_tim_emulate_stop();
|
||||
|
||||
/**
|
||||
* @brief config rfid timers to reset state
|
||||
*
|
||||
*/
|
||||
void furi_hal_rfid_tim_reset();
|
||||
|
||||
/**
|
||||
* @brief check that timer instance is emulation timer
|
||||
*
|
||||
* @param hw timer instance
|
||||
*/
|
||||
bool furi_hal_rfid_is_tim_emulate(TIM_HandleTypeDef* hw);
|
||||
|
||||
/**
|
||||
* @brief set emulation timer period
|
||||
*
|
||||
* @param period overall duration
|
||||
*/
|
||||
void furi_hal_rfid_set_emulate_period(uint32_t period);
|
||||
|
||||
/**
|
||||
* @brief set emulation timer pulse
|
||||
*
|
||||
* @param pulse duration of high level
|
||||
*/
|
||||
void furi_hal_rfid_set_emulate_pulse(uint32_t pulse);
|
||||
|
||||
/**
|
||||
* @brief set read timer period
|
||||
*
|
||||
* @param period overall duration
|
||||
*/
|
||||
void furi_hal_rfid_set_read_period(uint32_t period);
|
||||
|
||||
/**
|
||||
* @brief set read timer pulse
|
||||
*
|
||||
* @param pulse duration of high level
|
||||
*/
|
||||
void furi_hal_rfid_set_read_pulse(uint32_t pulse);
|
||||
|
||||
/**
|
||||
* Сhanges the configuration of the RFID timer "on a fly"
|
||||
* @param freq new frequency
|
||||
* @param duty_cycle new duty cycle
|
||||
*/
|
||||
void furi_hal_rfid_change_read_config(float freq, float duty_cycle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
23
firmware/targets/furi-hal-include/furi-hal-sd.h
Normal file
23
firmware/targets/furi-hal-include/furi-hal-sd.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Init SD card detect */
|
||||
void hal_sd_detect_init(void);
|
||||
|
||||
/** Set SD card detect pin to low */
|
||||
void hal_sd_detect_set_low(void);
|
||||
|
||||
/**
|
||||
* Get SD card status
|
||||
* @return true if SD card present
|
||||
* @return false if SD card not present
|
||||
*/
|
||||
bool hal_sd_detect(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
172
firmware/targets/furi-hal-include/furi-hal-subghz.h
Normal file
172
firmware/targets/furi-hal-include/furi-hal-subghz.h
Normal file
@@ -0,0 +1,172 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <toolbox/level_duration.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Radio Presets */
|
||||
typedef enum {
|
||||
FuriHalSubGhzPresetOokAsync, /** OOK, asynchronous */
|
||||
} FuriHalSubGhzPreset;
|
||||
|
||||
/** Switchable Radio Paths */
|
||||
typedef enum {
|
||||
FuriHalSubGhzPathIsolate, /** Isolate Radio from antenna */
|
||||
FuriHalSubGhzPath433, /** Center Frquency: 433MHz. Path 1: SW1RF1-SW2RF2, LCLCL */
|
||||
FuriHalSubGhzPath315, /** Center Frquency: 315MHz. Path 2: SW1RF2-SW2RF1, LCLCLCL */
|
||||
FuriHalSubGhzPath868, /** Center Frquency: 868MHz. Path 3: SW1RF3-SW2RF3, LCLC */
|
||||
} FuriHalSubGhzPath;
|
||||
|
||||
/** SubGhz state */
|
||||
typedef enum {
|
||||
SubGhzStateInit, /** Init pending */
|
||||
|
||||
SubGhzStateIdle, /** Idle, energy save mode */
|
||||
|
||||
SubGhzStateAsyncRx, /** Async RX started */
|
||||
|
||||
SubGhzStateAsyncTx, /** Async TX started, DMA and timer is on */
|
||||
SubGhzStateAsyncTxLast, /** Async TX continue, DMA completed and timer got last value to go */
|
||||
SubGhzStateAsyncTxEnd, /** Async TX complete, cleanup needed */
|
||||
} SubGhzState;
|
||||
|
||||
/** Initialize and switch to power save mode
|
||||
* Used by internal API-HAL initalization routine
|
||||
* Can be used to reinitialize device to safe state and send it to sleep
|
||||
*/
|
||||
void furi_hal_subghz_init();
|
||||
|
||||
/** Send device to sleep mode */
|
||||
void furi_hal_subghz_sleep();
|
||||
|
||||
/** Dump info to stdout */
|
||||
void furi_hal_subghz_dump_state();
|
||||
|
||||
/** Load registers from preset by preset name
|
||||
* @param preset to load
|
||||
*/
|
||||
void furi_hal_subghz_load_preset(FuriHalSubGhzPreset preset);
|
||||
|
||||
/** Get status */
|
||||
uint8_t furi_hal_subghz_get_status();
|
||||
|
||||
/** Load registers
|
||||
* @param register-value pairs array, terminated with {0,0}
|
||||
*/
|
||||
void furi_hal_subghz_load_registers(const uint8_t data[][2]);
|
||||
|
||||
/** Load PATABLE
|
||||
* @param data, 8 uint8_t values
|
||||
*/
|
||||
void furi_hal_subghz_load_patable(const uint8_t data[8]);
|
||||
|
||||
/** Write packet to FIFO
|
||||
* @param data, bytes array
|
||||
* @param size, size
|
||||
*/
|
||||
void furi_hal_subghz_write_packet(const uint8_t* data, uint8_t size);
|
||||
|
||||
/** Read packet from FIFO
|
||||
* @param data, pointer
|
||||
* @param size, size
|
||||
*/
|
||||
void furi_hal_subghz_read_packet(uint8_t* data, uint8_t* size);
|
||||
|
||||
/** Flush rx FIFO buffer */
|
||||
void furi_hal_subghz_flush_rx();
|
||||
|
||||
/** Shutdown
|
||||
* Issue spwd command
|
||||
* @warning registers content will be lost
|
||||
*/
|
||||
void furi_hal_subghz_shutdown();
|
||||
|
||||
/** Reset
|
||||
* Issue reset command
|
||||
* @warning registers content will be lost
|
||||
*/
|
||||
void furi_hal_subghz_reset();
|
||||
|
||||
/** Switch to Idle */
|
||||
void furi_hal_subghz_idle();
|
||||
|
||||
/** Switch to Recieve */
|
||||
void furi_hal_subghz_rx();
|
||||
|
||||
/** Switch to Transmit */
|
||||
void furi_hal_subghz_tx();
|
||||
|
||||
/** Get RSSI value in dBm */
|
||||
float furi_hal_subghz_get_rssi();
|
||||
|
||||
/** Check if frequency is in valid range
|
||||
* @return true if frequncy is valid, otherwise false
|
||||
*/
|
||||
bool furi_hal_subghz_is_frequency_valid(uint32_t value);
|
||||
|
||||
/** Set frequency and path
|
||||
* This function automatically selects antenna matching network
|
||||
* @param frequency in herz
|
||||
* @return real frequency in herz
|
||||
*/
|
||||
uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value);
|
||||
|
||||
/** Set frequency
|
||||
* @param frequency in herz
|
||||
* @return real frequency in herz
|
||||
*/
|
||||
uint32_t furi_hal_subghz_set_frequency(uint32_t value);
|
||||
|
||||
/** Set path
|
||||
* @param radio path to use
|
||||
*/
|
||||
void furi_hal_subghz_set_path(FuriHalSubGhzPath path);
|
||||
|
||||
/* High Level API */
|
||||
|
||||
/** Signal Timings Capture callback */
|
||||
typedef void (*FuriHalSubGhzCaptureCallback)(bool level, uint32_t duration, void* context);
|
||||
|
||||
/** Set signal timings capture callback
|
||||
* @param callback - your callback for front capture
|
||||
*/
|
||||
void furi_hal_subghz_set_async_rx_callback(FuriHalSubGhzCaptureCallback callback, void* context);
|
||||
|
||||
/** Enable signal timings capture
|
||||
* Initializes GPIO and TIM2 for timings capture
|
||||
*/
|
||||
void furi_hal_subghz_start_async_rx();
|
||||
|
||||
/** Disable signal timings capture
|
||||
* Resets GPIO and TIM2
|
||||
*/
|
||||
void furi_hal_subghz_stop_async_rx();
|
||||
|
||||
/** Send buffer
|
||||
* Initializes GPIO, TIM2 and DMA1 for signal output
|
||||
* @param buffer - pointer to data buffer
|
||||
* @param buffer_size - buffer size in bytes
|
||||
*/
|
||||
void furi_hal_subghz_start_async_tx(uint32_t* buffer, size_t buffer_size, size_t repeat);
|
||||
|
||||
/** Get repeats left count for async tx
|
||||
* @return packets left to send
|
||||
*/
|
||||
size_t furi_hal_subghz_get_async_tx_repeat_left();
|
||||
|
||||
/** Wait for async transmission to complete */
|
||||
void furi_hal_subghz_wait_async_tx();
|
||||
|
||||
/** Stop async transmission and cleanup resources
|
||||
* Resets GPIO, TIM2, and DMA1
|
||||
*/
|
||||
void furi_hal_subghz_stop_async_tx();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
45
firmware/targets/furi-hal-include/furi-hal-vcp.h
Normal file
45
firmware/targets/furi-hal-include/furi-hal-vcp.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Init VCP HAL
|
||||
* Allocates ring buffer and initializes state
|
||||
*/
|
||||
void furi_hal_vcp_init();
|
||||
|
||||
/**
|
||||
* Recieve data from VCP
|
||||
* Waits till some data arrives, never returns 0
|
||||
* @param buffer - pointer to buffer
|
||||
* @param size - buffer size
|
||||
* @return items copied in buffer, 0 if channel closed
|
||||
*/
|
||||
size_t furi_hal_vcp_rx(uint8_t* buffer, size_t size);
|
||||
|
||||
/**
|
||||
* Recieve data from VCP with timeout
|
||||
* Waits till some data arrives during timeout
|
||||
* @param buffer - pointer to buffer
|
||||
* @param size - buffer size
|
||||
* @param timeout - rx timeout in ms
|
||||
* @return items copied in buffer, 0 if channel closed or timeout occurs
|
||||
*/
|
||||
size_t furi_hal_vcp_rx_with_timeout(uint8_t* buffer, size_t size, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* Transmit data to VCP
|
||||
* @param buffer - pointer to buffer
|
||||
* @param size - buffer size
|
||||
*/
|
||||
void furi_hal_vcp_tx(const uint8_t* buffer, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
90
firmware/targets/furi-hal-include/furi-hal-version.h
Normal file
90
firmware/targets/furi-hal-include/furi-hal-version.h
Normal file
@@ -0,0 +1,90 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <lib/toolbox/version.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Device Colors */
|
||||
typedef enum {
|
||||
FuriHalVersionColorUnknown=0x00,
|
||||
FuriHalVersionColorBlack=0x01,
|
||||
FuriHalVersionColorWhite=0x02,
|
||||
} FuriHalVersionColor;
|
||||
|
||||
/** Device Regions */
|
||||
typedef enum {
|
||||
FuriHalVersionRegionUnknown=0x00,
|
||||
FuriHalVersionRegionEuRu=0x01,
|
||||
FuriHalVersionRegionUsCaAu=0x02,
|
||||
FuriHalVersionRegionJp=0x03,
|
||||
} FuriHalVersionRegion;
|
||||
|
||||
/** Init flipper version */
|
||||
void furi_hal_version_init();
|
||||
|
||||
/** Check target firmware version */
|
||||
bool furi_hal_version_do_i_belong_here();
|
||||
|
||||
/** Get model name */
|
||||
const char* furi_hal_version_get_model_name();
|
||||
|
||||
/** Get hardware version */
|
||||
const uint8_t furi_hal_version_get_hw_version();
|
||||
|
||||
/** Get hardware target */
|
||||
const uint8_t furi_hal_version_get_hw_target();
|
||||
|
||||
/** Get hardware body */
|
||||
const uint8_t furi_hal_version_get_hw_body();
|
||||
|
||||
/** Get hardware body color */
|
||||
const FuriHalVersionColor furi_hal_version_get_hw_color();
|
||||
|
||||
/** Get hardware connect */
|
||||
const uint8_t furi_hal_version_get_hw_connect();
|
||||
|
||||
/** Get hardware region */
|
||||
const FuriHalVersionRegion furi_hal_version_get_hw_region();
|
||||
|
||||
/** Get hardware timestamp */
|
||||
const uint32_t furi_hal_version_get_hw_timestamp();
|
||||
|
||||
/** Get pointer to target name */
|
||||
const char* furi_hal_version_get_name_ptr();
|
||||
|
||||
/** Get pointer to target device name */
|
||||
const char* furi_hal_version_get_device_name_ptr();
|
||||
|
||||
/** Get pointer to target ble local device name */
|
||||
const char* furi_hal_version_get_ble_local_device_name_ptr();
|
||||
|
||||
const uint8_t* furi_hal_version_get_ble_mac();
|
||||
|
||||
/**
|
||||
* Get address of version structure of bootloader, stored in chip flash.
|
||||
*
|
||||
* @return Address of boot version structure.
|
||||
*/
|
||||
const struct Version* furi_hal_version_get_boot_version(void);
|
||||
|
||||
/**
|
||||
* Get address of version structure of firmware.
|
||||
*
|
||||
* @return Address of firmware version structure.
|
||||
*/
|
||||
const struct Version* furi_hal_version_get_firmware_version(void);
|
||||
|
||||
/** Get platform UID size in bytes */
|
||||
size_t furi_hal_version_uid_size();
|
||||
|
||||
/** Get const pointer to UID */
|
||||
const uint8_t* furi_hal_version_uid();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
19
firmware/targets/furi-hal-include/furi-hal-vibro.h
Normal file
19
firmware/targets/furi-hal-include/furi-hal-vibro.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <furi-hal-resources.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Initialize vibro */
|
||||
void furi_hal_vibro_init();
|
||||
|
||||
/** Turn on/off vibro */
|
||||
void furi_hal_vibro_on(bool value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
32
firmware/targets/furi-hal-include/furi-hal.h
Normal file
32
firmware/targets/furi-hal-include/furi-hal.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
template <unsigned int N> struct STOP_EXTERNING_ME {};
|
||||
#endif
|
||||
|
||||
#include "furi-hal-boot.h"
|
||||
#include "furi-hal-clock.h"
|
||||
#include "furi-hal-console.h"
|
||||
#include "furi-hal-os.h"
|
||||
#include "furi-hal-i2c.h"
|
||||
#include "furi-hal-resources.h"
|
||||
#include "furi-hal-gpio.h"
|
||||
#include "furi-hal-light.h"
|
||||
#include "furi-hal-delay.h"
|
||||
#include "furi-hal-pwm.h"
|
||||
#include "furi-hal-task.h"
|
||||
#include "furi-hal-power.h"
|
||||
#include "furi-hal-vcp.h"
|
||||
#include "furi-hal-interrupt.h"
|
||||
#include "furi-hal-version.h"
|
||||
#include "furi-hal-bt.h"
|
||||
#include "furi-hal-spi.h"
|
||||
#include "furi-hal-flash.h"
|
||||
#include "furi-hal-subghz.h"
|
||||
#include "furi-hal-vibro.h"
|
||||
#include "furi-hal-ibutton.h"
|
||||
#include "furi-hal-rfid.h"
|
||||
#include "furi-hal-nfc.h"
|
||||
|
||||
/** Init furi-hal */
|
||||
void furi_hal_init();
|
Reference in New Issue
Block a user