Naming and coding style convention, new linter tool. (#945)

* Makefile, Scripts: new linter
* About: remove ID from IC
* Firmware: remove double define for DIVC/DIVR
* Scripts: check folder names too. Docker: replace syntax check with make lint.
* Reformat Sources and Migrate to new file naming convention
* Docker: symlink clang-format-12 to clang-format
* Add coding style guide
This commit is contained in:
あく
2022-01-05 19:10:18 +03:00
committed by GitHub
parent c98e54da10
commit 389ff92cc1
899 changed files with 379245 additions and 373421 deletions

View File

@@ -0,0 +1,15 @@
#pragma once
#include <furi_hal_i2c.h>
#include <furi_hal_light.h>
#include <furi_hal_resources.h>
#include <furi_hal_spi.h>
#include <furi_hal_version.h>
#define furi_assert(value) (void)(value)
void furi_hal_init();
void delay(float milliseconds);
void delay_us(float microseconds);

View File

@@ -0,0 +1,102 @@
#pragma once
#include <furi_hal_spi_config.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Initialize SPI HAL */
void furi_hal_spi_init();
/** Initialize SPI Bus
*
* @param handle pointer to FuriHalSpiBus instance
*/
void furi_hal_spi_bus_init(FuriHalSpiBus* bus);
/** Deinitialize SPI Bus
*
* @param handle pointer to FuriHalSpiBus instance
*/
void furi_hal_spi_bus_deinit(FuriHalSpiBus* bus);
/** Initialize SPI Bus Handle
*
* @param handle pointer to FuriHalSpiBusHandle instance
*/
void furi_hal_spi_bus_handle_init(FuriHalSpiBusHandle* handle);
/** Deinitialize SPI Bus Handle
*
* @param handle pointer to FuriHalSpiBusHandle instance
*/
void furi_hal_spi_bus_handle_deinit(FuriHalSpiBusHandle* handle);
/** Acquire SPI bus
*
* @warning blocking, calls `furi_crash` on programming error, CS transition is up to handler event routine
*
* @param handle pointer to FuriHalSpiBusHandle instance
*/
void furi_hal_spi_acquire(FuriHalSpiBusHandle* handle);
/** Release SPI bus
*
* @warning calls `furi_crash` on programming error, CS transition is up to handler event routine
*
* @param handle pointer to FuriHalSpiBusHandle instance
*/
void furi_hal_spi_release(FuriHalSpiBusHandle* handle);
/** SPI Receive
*
* @param handle pointer to FuriHalSpiBusHandle instance
* @param buffer receive buffer
* @param size transaction size (buffer size)
* @param timeout operation timeout in ms
*
* @return true on sucess
*/
bool furi_hal_spi_bus_rx(
FuriHalSpiBusHandle* handle,
uint8_t* buffer,
size_t size,
uint32_t timeout);
/** SPI Transmit
*
* @param handle pointer to FuriHalSpiBusHandle instance
* @param buffer transmit buffer
* @param size transaction size (buffer size)
* @param timeout operation timeout in ms
*
* @return true on success
*/
bool furi_hal_spi_bus_tx(
FuriHalSpiBusHandle* handle,
uint8_t* buffer,
size_t size,
uint32_t timeout);
/** SPI Transmit and Receive
*
* @param handle pointer to FuriHalSpiBusHandle instance
* @param tx_buffer pointer to tx buffer
* @param rx_buffer pointer to rx buffer
* @param size transaction size (buffer size)
* @param timeout operation timeout in ms
*
* @return true on success
*/
bool furi_hal_spi_bus_trx(
FuriHalSpiBusHandle* handle,
uint8_t* tx_buffer,
uint8_t* rx_buffer,
size_t size,
uint32_t timeout);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,173 @@
/**
* @file furi_hal_version.h
* Version HAL API
*/
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <lib/toolbox/version.h>
#ifdef __cplusplus
extern "C" {
#endif
#define FURI_HAL_VERSION_NAME_LENGTH 8
#define FURI_HAL_VERSION_ARRAY_NAME_LENGTH (FURI_HAL_VERSION_NAME_LENGTH + 1)
/** BLE symbol + "Flipper " + name */
#define FURI_HAL_VERSION_DEVICE_NAME_LENGTH (1 + 8 + FURI_HAL_VERSION_ARRAY_NAME_LENGTH)
/** OTP Versions enum */
typedef enum {
FuriHalVersionOtpVersion0 = 0x00,
FuriHalVersionOtpVersion1 = 0x01,
FuriHalVersionOtpVersion2 = 0x02,
FuriHalVersionOtpVersionEmpty = 0xFFFFFFFE,
FuriHalVersionOtpVersionUnknown = 0xFFFFFFFF,
} FuriHalVersionOtpVersion;
/** Device Colors */
typedef enum {
FuriHalVersionColorUnknown = 0x00,
FuriHalVersionColorBlack = 0x01,
FuriHalVersionColorWhite = 0x02,
} FuriHalVersionColor;
/** Device Regions */
typedef enum {
FuriHalVersionRegionUnknown = 0x00,
FuriHalVersionRegionEuRu = 0x01,
FuriHalVersionRegionUsCaAu = 0x02,
FuriHalVersionRegionJp = 0x03,
} FuriHalVersionRegion;
/** Device Display */
typedef enum {
FuriHalVersionDisplayUnknown = 0x00,
FuriHalVersionDisplayErc = 0x01,
FuriHalVersionDisplayMgg = 0x02,
} FuriHalVersionDisplay;
/** Init flipper version
*/
void furi_hal_version_init();
/** Check target firmware version
*
* @return true if target and real matches
*/
bool furi_hal_version_do_i_belong_here();
/** Get model name
*
* @return model name C-string
*/
const char* furi_hal_version_get_model_name();
/** Get OTP version
*
* @return OTP Version
*/
const FuriHalVersionOtpVersion furi_hal_version_get_otp_version();
/** Get hardware version
*
* @return Hardware Version
*/
const uint8_t furi_hal_version_get_hw_version();
/** Get hardware target
*
* @return Hardware Target
*/
const uint8_t furi_hal_version_get_hw_target();
/** Get hardware body
*
* @return Hardware Body
*/
const uint8_t furi_hal_version_get_hw_body();
/** Get hardware body color
*
* @return Hardware Color
*/
const FuriHalVersionColor furi_hal_version_get_hw_color();
/** Get hardware connect
*
* @return Hardware Interconnect
*/
const uint8_t furi_hal_version_get_hw_connect();
/** Get hardware region
*
* @return Hardware Region
*/
const FuriHalVersionRegion furi_hal_version_get_hw_region();
/** Get hardware display id
*
* @return Display id
*/
const FuriHalVersionDisplay furi_hal_version_get_hw_display();
/** Get hardware timestamp
*
* @return Hardware Manufacture timestamp
*/
const uint32_t furi_hal_version_get_hw_timestamp();
/** Get pointer to target name
*
* @return Hardware Name C-string
*/
const char* furi_hal_version_get_name_ptr();
/** Get pointer to target device name
*
* @return Hardware Device Name C-string
*/
const char* furi_hal_version_get_device_name_ptr();
/** Get pointer to target ble local device name
*
* @return Ble Device Name C-string
*/
const char* furi_hal_version_get_ble_local_device_name_ptr();
/** Get BLE MAC address
*
* @return pointer to BLE MAC address
*/
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_bootloader_version();
/** Get address of version structure of firmware.
*
* @return Address of firmware version structure.
*/
const struct Version* furi_hal_version_get_firmware_version();
/** Get platform UID size in bytes
*
* @return UID size in bytes
*/
size_t furi_hal_version_uid_size();
/** Get const pointer to UID
*
* @return pointer to UID
*/
const uint8_t* furi_hal_version_uid();
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,25 @@
#ifndef TARGET_H
#define TARGET_H
/**
* Initialize hardware
*/
void target_init();
/**
* Check if dfu mode requested
* @return 1 if dfu mode requested, 0 if not
*/
int target_is_dfu_requested();
/**
* Switch to dfu mode
*/
void target_switch2dfu();
/**
* Switch to OS
*/
void target_switch2os();
#endif