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,65 @@
#include "api_interrupt_mgr.h"
#include <cmsis_os2.h>
#include <furi.h>
static volatile InterruptCallbackItem callback_list[InterruptTypeLast];
bool api_interrupt_init() {
for(uint8_t i = 0; i < InterruptTypeLast; i++) {
callback_list[i].callback = NULL;
callback_list[i].context = NULL;
callback_list[i].ready = false;
}
return true;
}
void api_interrupt_add(InterruptCallback callback, InterruptType type, void* context) {
furi_assert(type < InterruptTypeLast);
furi_check(callback_list[type].callback == NULL);
callback_list[type].callback = callback;
callback_list[type].context = context;
__DMB();
callback_list[type].ready = true;
}
void api_interrupt_remove(InterruptCallback callback, InterruptType type) {
furi_assert(type < InterruptTypeLast);
if(callback_list[type].callback != NULL) {
furi_check(callback_list[type].callback == callback);
}
callback_list[type].ready = false;
__DMB();
callback_list[type].callback = NULL;
callback_list[type].context = NULL;
}
void api_interrupt_enable(InterruptCallback callback, InterruptType type) {
furi_assert(type < InterruptTypeLast);
furi_check(callback_list[type].callback == callback);
callback_list[type].ready = true;
__DMB();
}
void api_interrupt_disable(InterruptCallback callback, InterruptType type) {
furi_assert(type < InterruptTypeLast);
furi_check(callback_list[type].callback == callback);
callback_list[type].ready = false;
__DMB();
}
void api_interrupt_call(InterruptType type, void* hw) {
// that executed in interrupt ctx so mutex don't needed
// but we need to check ready flag
furi_assert(type < InterruptTypeLast);
if(callback_list[type].callback != NULL) {
if(callback_list[type].ready) {
callback_list[type].callback(hw, callback_list[type].context);
}
}
}

View File

@@ -0,0 +1,75 @@
/**
* @file api_interrupt_mgr.h
* Furi: interrupt API
*/
#pragma once
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Interrupt callback prototype */
typedef void (*InterruptCallback)(void*, void*);
/** Interupt type */
typedef enum {
InterruptTypeComparatorTrigger,
InterruptTypeTimerUpdate,
InterruptTypeLast,
} InterruptType;
/** Interrupt callback type */
typedef struct {
InterruptCallback callback;
void* context;
bool ready;
} InterruptCallbackItem;
/** Init interrupt
*
* @return true on succsessful initialization, false otherwise
*/
bool api_interrupt_init();
/** Add interrupt
*
* @param callback InterruptCallback
* @param type InterruptType
* @param context context for callback
*/
void api_interrupt_add(InterruptCallback callback, InterruptType type, void* context);
/** Remove interrupt
*
* @param callback InterruptCallback
* @param type InterruptType
*/
void api_interrupt_remove(InterruptCallback callback, InterruptType type);
/** Enable interrupt
*
* @param callback InterruptCallback
* @param type InterruptType
*/
void api_interrupt_enable(InterruptCallback callback, InterruptType type);
/** Disable interrupt
*
* @param callback InterruptCallback
* @param type InterruptType
*/
void api_interrupt_disable(InterruptCallback callback, InterruptType type);
/** Call interrupt
*
* @param type InterruptType
* @param hw pointer to hardware peripheral
*/
void api_interrupt_call(InterruptType type, void* hw);
#ifdef __cplusplus
}
#endif