diff --git a/applications/app-loader/app-loader.c b/applications/app-loader/app-loader.c index bc170e85..a01f9835 100644 --- a/applications/app-loader/app-loader.c +++ b/applications/app-loader/app-loader.c @@ -7,12 +7,12 @@ typedef struct { FuriApp* handler; Widget* widget; - FlipperStartupApp* current_app; + const FlipperStartupApp* current_app; } AppLoaderState; typedef struct { AppLoaderState* state; - FlipperStartupApp* app; + const FlipperStartupApp* app; } AppLoaderContext; // TODO add mutex for contex diff --git a/applications/cc1101-workaround/cc1101-workaround.cpp b/applications/cc1101-workaround/cc1101-workaround.cpp index b794bd23..03556fa1 100644 --- a/applications/cc1101-workaround/cc1101-workaround.cpp +++ b/applications/cc1101-workaround/cc1101-workaround.cpp @@ -54,7 +54,7 @@ void setup_freq(CC1101* cc1101, const FreqConfig* config) { int16_t rx_rssi(CC1101* cc1101, const FreqConfig* config) { cc1101->SetReceive(); - delayMicroseconds(RSSI_DELAY); + delay_us(RSSI_DELAY); // 1.4.8) read PKTSTATUS register while the radio is in RX state /*uint8_t _pkt_status = */ cc1101->SpiReadStatus(CC1101_PKTSTATUS); @@ -262,7 +262,7 @@ extern "C" void cc1101_workaround(void* p) { GpioPin* led_record = &led; // configure pin - pinMode(led_record, GpioModeOutputOpenDrain); + gpio_init(led_record, GpioModeOutputOpenDrain); const int16_t RSSI_THRESHOLD = -89; @@ -327,9 +327,9 @@ extern "C" void cc1101_workaround(void* p) { state->need_cc1101_conf = false; } - digitalWrite( + gpio_write( led_record, - (state->last_rssi > RSSI_THRESHOLD && !state->need_cc1101_conf) ? LOW : HIGH); + (state->last_rssi > RSSI_THRESHOLD && !state->need_cc1101_conf) ? false : true); release_mutex(&state_mutex, state); widget_update(widget); diff --git a/applications/cc1101-workaround/cc1101.cpp b/applications/cc1101-workaround/cc1101.cpp index 279e1256..1feae6b1 100644 --- a/applications/cc1101-workaround/cc1101.cpp +++ b/applications/cc1101-workaround/cc1101.cpp @@ -17,7 +17,7 @@ CC1101::CC1101(GpioPin* ss_pin) { pinMode(gdo0_pin, OUTPUT); //GDO0 as asynchronous serial mode input pinMode(gdo2_pin, INPUT); //GDO2 as asynchronous serial mode output */ - pinMode(ss_pin, OUTPUT); + gpio_init(ss_pin, GpioModeOutputPushPull); this->ss_pin = ss_pin; // TODO open record @@ -79,9 +79,9 @@ Function: SpiMode (1<miso_pin_record)) +void CC1101::SpiWriteReg(uint8_t addr, uint8_t value) { + gpio_write(ss_pin, false); + while(gpio_read(this->miso_pin_record)) ; SpiTransfer(addr); SpiTransfer(value); - digitalWrite(ss_pin, HIGH); + gpio_write(ss_pin, true); } /**************************************************************** @@ -125,18 +125,18 @@ void CC1101::SpiWriteReg(byte addr, byte value) { *INPUT :addr: register address; buffer:register value array; num:number to write *OUTPUT :none ****************************************************************/ -void CC1101::SpiWriteBurstReg(byte addr, byte* buffer, byte num) { - byte i, temp; +void CC1101::SpiWriteBurstReg(uint8_t addr, uint8_t* buffer, uint8_t num) { + uint8_t i, temp; temp = addr | WRITE_BURST; - digitalWrite(ss_pin, LOW); - while(digitalRead(this->miso_pin_record)) + gpio_write(ss_pin, false); + while(gpio_read(this->miso_pin_record)) ; SpiTransfer(temp); for(i = 0; i < num; i++) { SpiTransfer(buffer[i]); } - digitalWrite(ss_pin, HIGH); + gpio_write(ss_pin, true); } /**************************************************************** @@ -145,12 +145,12 @@ void CC1101::SpiWriteBurstReg(byte addr, byte* buffer, byte num) { *INPUT :strobe: command; //refer define in CC1101.h// *OUTPUT :none ****************************************************************/ -void CC1101::SpiStrobe(byte strobe) { - digitalWrite(ss_pin, LOW); - while(digitalRead(this->miso_pin_record)) +void CC1101::SpiStrobe(uint8_t strobe) { + gpio_write(ss_pin, false); + while(gpio_read(this->miso_pin_record)) ; SpiTransfer(strobe); - digitalWrite(ss_pin, HIGH); + gpio_write(ss_pin, true); } /**************************************************************** @@ -159,16 +159,16 @@ void CC1101::SpiStrobe(byte strobe) { *INPUT :addr: register address *OUTPUT :register value ****************************************************************/ -byte CC1101::SpiReadReg(byte addr) { - byte temp, value; +uint8_t CC1101::SpiReadReg(uint8_t addr) { + uint8_t temp, value; temp = addr | READ_SINGLE; - digitalWrite(ss_pin, LOW); - while(digitalRead(this->miso_pin_record)) + gpio_write(ss_pin, false); + while(gpio_read(this->miso_pin_record)) ; SpiTransfer(temp); value = SpiTransfer(0); - digitalWrite(ss_pin, HIGH); + gpio_write(ss_pin, true); return value; } @@ -179,18 +179,18 @@ byte CC1101::SpiReadReg(byte addr) { *INPUT :addr: register address; buffer:array to store register value; num: number to read *OUTPUT :none ****************************************************************/ -void CC1101::SpiReadBurstReg(byte addr, byte* buffer, byte num) { - byte i, temp; +void CC1101::SpiReadBurstReg(uint8_t addr, uint8_t* buffer, uint8_t num) { + uint8_t i, temp; temp = addr | READ_BURST; - digitalWrite(ss_pin, LOW); - while(digitalRead(this->miso_pin_record)) + gpio_write(ss_pin, false); + while(gpio_read(this->miso_pin_record)) ; SpiTransfer(temp); for(i = 0; i < num; i++) { buffer[i] = SpiTransfer(0); } - digitalWrite(ss_pin, HIGH); + gpio_write(ss_pin, true); } /**************************************************************** @@ -199,16 +199,16 @@ void CC1101::SpiReadBurstReg(byte addr, byte* buffer, byte num) { *INPUT :addr: register address *OUTPUT :status value ****************************************************************/ -byte CC1101::SpiReadStatus(byte addr) { - byte value, temp; +uint8_t CC1101::SpiReadStatus(uint8_t addr) { + uint8_t value, temp; temp = addr | READ_BURST; - digitalWrite(ss_pin, LOW); - while(digitalRead(this->miso_pin_record)) + gpio_write(ss_pin, false); + while(gpio_read(this->miso_pin_record)) ; SpiTransfer(temp); value = SpiTransfer(0); - digitalWrite(ss_pin, HIGH); + gpio_write(ss_pin, true); return value; } @@ -220,17 +220,17 @@ byte CC1101::SpiReadStatus(byte addr) { *OUTPUT :none ****************************************************************/ void CC1101::Reset(void) { - digitalWrite(ss_pin, LOW); + gpio_write(ss_pin, false); delay(1); - digitalWrite(ss_pin, HIGH); + gpio_write(ss_pin, true); delay(1); - digitalWrite(ss_pin, LOW); - while(digitalRead(this->miso_pin_record)) + gpio_write(ss_pin, false); + while(gpio_read(this->miso_pin_record)) ; SpiTransfer(CC1101_SRES); - while(digitalRead(this->miso_pin_record)) + while(gpio_read(this->miso_pin_record)) ; - digitalWrite(ss_pin, HIGH); + gpio_write(ss_pin, true); } /**************************************************************** *FUNCTION NAME:Init @@ -238,20 +238,21 @@ void CC1101::Reset(void) { *INPUT :none *OUTPUT :none ****************************************************************/ -byte CC1101::Init(void) { +uint8_t CC1101::Init(void) { #ifdef CC1101_DEBUG printf("Init SPI...\n"); #endif SpiInit(); //spi initialization - digitalWrite(ss_pin, HIGH); -// digitalWrite(SCK_PIN, HIGH); -// digitalWrite(MOSI_PIN, LOW); + gpio_write(ss_pin, true); +// gpio_write(SCK_PIN, true); +// gpio_write(MOSI_PIN, false); #ifdef CC1101_DEBUG printf("Reset CC1101...\n"); #endif Reset(); //CC1101 reset - byte partnum, version; + uint8_t partnum __attribute__((unused)); + uint8_t version; partnum = SpiReadStatus(CC1101_PARTNUM); version = SpiReadStatus(CC1101_VERSION); @@ -277,15 +278,15 @@ byte CC1101::Init(void) { *INPUT :byte mode *OUTPUT :none ****************************************************************/ -void CC1101::SetMod(byte mode) { +void CC1101::SetMod(uint8_t mode) { SpiWriteReg(CC1101_MDMCFG2, mode); //no sync/preamble; ASK/OOK only support up to -1dbm if((mode | 0x30) == ASK) { SpiWriteReg(CC1101_FREND0, 0x11); //use first up to PATABLE(0) - byte PaTabel[8] = {0x00, POWER, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + uint8_t PaTabel[8] = {0x00, POWER, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; SpiWriteBurstReg(CC1101_PATABLE, PaTabel, 8); //CC1101 PATABLE config } else { SpiWriteReg(CC1101_FREND0, 0x10); //use first up to PATABLE(0) - byte PaTabel[8] = {POWER, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + uint8_t PaTabel[8] = {POWER, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; SpiWriteBurstReg(CC1101_PATABLE, PaTabel, 8); //CC1101 PATABLE config } @@ -377,7 +378,7 @@ void CC1101::RegConfigSettings(void) { *INPUT :Freq2, Freq1, Freq0 *OUTPUT :none ****************************************************************/ -void CC1101::SetFreq(byte freq2, byte freq1, byte freq0) { +void CC1101::SetFreq(uint8_t freq2, uint8_t freq1, uint8_t freq0) { SpiWriteReg(CC1101_FREQ2, freq2); SpiWriteReg(CC1101_FREQ1, freq1); SpiWriteReg(CC1101_FREQ0, freq0); @@ -392,7 +393,7 @@ void CC1101::SetChannel(int channel) { #ifdef CC1101_DEBUG printf("Set CC1101 channel to: %d \n", channel); #endif - SpiWriteReg(CC1101_CHANNR, (byte)channel); //related to channel numbers + SpiWriteReg(CC1101_CHANNR, (uint8_t)channel); //related to channel numbers } /**************************************************************** *FUNCTION NAME:SetReceive diff --git a/applications/cc1101-workaround/cc1101.h b/applications/cc1101-workaround/cc1101.h index 862e4525..aa4b7cfe 100644 --- a/applications/cc1101-workaround/cc1101.h +++ b/applications/cc1101-workaround/cc1101.h @@ -143,25 +143,25 @@ private: GpioPin* gdo2_pin; private: - void SpiMode(byte config); - byte SpiTransfer(byte value); + void SpiMode(uint8_t config); + uint8_t SpiTransfer(uint8_t value); void Reset(void); - void SpiWriteBurstReg(byte addr, byte* buffer, byte num); - byte SpiReadReg(byte addr); - void SpiReadBurstReg(byte addr, byte* buffer, byte num); + void SpiWriteBurstReg(uint8_t addr, uint8_t* buffer, uint8_t num); + uint8_t SpiReadReg(uint8_t addr); + void SpiReadBurstReg(uint8_t addr, uint8_t* buffer, uint8_t num); void RegConfigSettings(void); public: CC1101(GpioPin* ss_pin); - void SpiWriteReg(byte addr, byte value); + void SpiWriteReg(uint8_t addr, uint8_t value); void SpiInit(void); void SpiEnd(void); - void SetMod(byte mode); - void SetFreq(byte Freq2, byte Freq1, byte Freq0); - byte Init(void); - void SpiStrobe(byte strobe); - byte SpiReadStatus(byte addr); + void SetMod(uint8_t mode); + void SetFreq(uint8_t Freq2, uint8_t Freq1, uint8_t Freq0); + uint8_t Init(void); + void SpiStrobe(uint8_t strobe); + uint8_t SpiReadStatus(uint8_t addr); void SetReceive(void); void SetTransmit(void); void SetChannel(int channel); diff --git a/applications/examples/blink.c b/applications/examples/blink.c index 195a13cf..abd0dd1c 100644 --- a/applications/examples/blink.c +++ b/applications/examples/blink.c @@ -9,12 +9,12 @@ void application_blink(void* p) { GpioPin* led_record = &led; // configure pin - pinMode(led_record, GpioModeOutputOpenDrain); + gpio_init(led_record, GpioModeOutputOpenDrain); while(1) { - digitalWrite(led_record, HIGH); + gpio_write(led_record, true); delay(500); - digitalWrite(led_record, LOW); + gpio_write(led_record, false); delay(500); } } \ No newline at end of file diff --git a/applications/examples/fatfs_list.c b/applications/examples/fatfs_list.c index de24124c..afb7fd63 100644 --- a/applications/examples/fatfs_list.c +++ b/applications/examples/fatfs_list.c @@ -3,6 +3,8 @@ #include "flipper_v2.h" #include +extern uint8_t BSP_SD_Init(); + // TODO currently we have small stack, so it will be static FuriRecordSubscriber* furi_log; #define STR_BUFFER_SIZE 128 @@ -72,8 +74,6 @@ void fatfs_list(void* p) { u8g2_ClearBuffer(fb); furi_commit(fb_record); - // TODO these lines should be executed in the target driver - // so i dont fix "implicit declaration of function 'BSP_SD_Init'" bsp_result = BSP_SD_Init(); if(bsp_result != 0) { diff --git a/applications/examples/input_dump.c b/applications/examples/input_dump.c index ce740d9c..fc794620 100644 --- a/applications/examples/input_dump.c +++ b/applications/examples/input_dump.c @@ -1,10 +1,16 @@ #include "flipper_v2.h" #include -static void state_cb(const void* value, void* ctx) { - const InputState* state = value; +typedef union { + unsigned int packed; + InputState state; +} InputDump; - printf("state: %02x\n", *state); +static void state_cb(const void* value, void* ctx) { + InputDump dump = {.packed = 0}; + dump.state = *(InputState*)value; + + printf("state: %02x\n", dump.packed); } static void event_cb(const void* value, void* ctx) { diff --git a/applications/examples/uart_write.c b/applications/examples/uart_write.c index 95d6ec49..217b1563 100644 --- a/applications/examples/uart_write.c +++ b/applications/examples/uart_write.c @@ -9,7 +9,7 @@ void application_uart_write(void* p) { // TODO open record GpioPin* led_record = &led; - pinMode(led_record, GpioModeOutputOpenDrain); + gpio_init(led_record, GpioModeOutputOpenDrain); // get_default_log open "tty" record FuriRecordSubscriber* log = get_default_log(); @@ -27,9 +27,9 @@ void application_uart_write(void* p) { counter++; // flash at every send - digitalWrite(led_record, LOW); + gpio_write(led_record, false); delay(50); - digitalWrite(led_record, HIGH); + gpio_write(led_record, true); // delay with overall perion of 1s delay(950); diff --git a/applications/irda/irda.c b/applications/irda/irda.c index 13747ef4..9dd8fec2 100644 --- a/applications/irda/irda.c +++ b/applications/irda/irda.c @@ -80,12 +80,10 @@ void render_carrier(CanvasApi* canvas, State* state) { canvas->draw_str(canvas, 2, 37, "? /\\ freq | \\/ duty cycle"); { char buf[24]; - sprintf(buf, "frequency: %d Hz", state->carrier_freq); + sprintf(buf, "frequency: %u Hz", state->carrier_freq); canvas->draw_str(canvas, 2, 50, buf); sprintf( - buf, - "duty cycle: %d/1000", - (uint32_t)(duty_cycles[state->carrier_duty_cycle_id] * 1000)); + buf, "duty cycle: %d/1000", (int)(duty_cycles[state->carrier_duty_cycle_id] * 1000)); canvas->draw_str(canvas, 2, 62, buf); } } diff --git a/applications/lf-rfid/lf-rfid.c b/applications/lf-rfid/lf-rfid.c index 48115de1..cc7f6253 100644 --- a/applications/lf-rfid/lf-rfid.c +++ b/applications/lf-rfid/lf-rfid.c @@ -28,7 +28,7 @@ static void render_callback(CanvasApi* canvas, void* ctx) { canvas->draw_str(canvas, 2, 24, state->on ? "ON" : "OFF"); char buf[12]; - sprintf(buf, "%d kHz", state->freq_khz); + sprintf(buf, "%d kHz", (int)state->freq_khz); canvas->draw_str(canvas, 2, 36, buf); release_mutex((ValueMutex*)ctx, state); diff --git a/applications/nfc/nfc.c b/applications/nfc/nfc.c index a87bf240..e5fe8908 100644 --- a/applications/nfc/nfc.c +++ b/applications/nfc/nfc.c @@ -15,6 +15,8 @@ #include #include +#include + #include "dispatcher.h" typedef enum { diff --git a/applications/power/power.c b/applications/power/power.c index 36804a16..665e9881 100644 --- a/applications/power/power.c +++ b/applications/power/power.c @@ -46,7 +46,7 @@ void power_draw_battery_callback(CanvasApi* canvas, void* context) { void power_input_events_callback(const void* value, void* ctx) { assert(ctx); Power* power = ctx; - InputEvent* event = value; + const InputEvent* event = value; if(event->input != InputCharging) return; @@ -63,7 +63,7 @@ Power* power_alloc() { ValueManager* input_state_manager = furi_open("input_state"); InputState input_state; - read_mutex_block(input_state_manager, &input_state, sizeof(input_state)); + read_mutex_block(&input_state_manager->value, &input_state, sizeof(input_state)); widget_enabled_set(power->usb_widget, input_state.charging); widget_draw_callback_set(power->usb_widget, power_draw_usb_callback, power); diff --git a/applications/tests/furi_event_test.c b/applications/tests/furi_event_test.c index f6b9a5e0..2edb0af8 100644 --- a/applications/tests/furi_event_test.c +++ b/applications/tests/furi_event_test.c @@ -18,7 +18,8 @@ void test_furi_event() { mu_check(!wait_event_with_timeout(&event, 100)); // Create second app - FuriApp* second_app = furiac_start(furi_concurent_app, "furi concurent app", (void*)&event); + FuriApp* second_app __attribute__((unused)) = + furiac_start(furi_concurent_app, "furi concurent app", (void*)&event); // The event should be signalled now mu_check(wait_event_with_timeout(&event, 100)); diff --git a/applications/tests/furi_pubsub_test.c b/applications/tests/furi_pubsub_test.c index 4447f542..5d3a0a9e 100644 --- a/applications/tests/furi_pubsub_test.c +++ b/applications/tests/furi_pubsub_test.c @@ -12,7 +12,7 @@ const uint32_t notify_value_1 = 0x11223344; uint32_t pubsub_value = 0; uint32_t pubsub_context_value = 0; -void test_pubsub_handler(void* arg, void* ctx) { +void test_pubsub_handler(const void* arg, void* ctx) { pubsub_value = *(uint32_t*)arg; pubsub_context_value = *(uint32_t*)ctx; } diff --git a/applications/tests/furi_value_expanders_test.c b/applications/tests/furi_value_expanders_test.c index 8a795a4e..5d9a965c 100644 --- a/applications/tests/furi_value_expanders_test.c +++ b/applications/tests/furi_value_expanders_test.c @@ -112,7 +112,7 @@ static const uint32_t notify_value_1 = 0x11223344; static uint32_t pubsub_value = 0; -void test_value_manager_handler(void* arg, void* ctx) { +void test_value_manager_handler(const void* arg, void* ctx) { pubsub_value = *(uint32_t*)arg; } diff --git a/applications/tests/minunit.h b/applications/tests/minunit.h index e7caee40..466cf9c1 100644 --- a/applications/tests/minunit.h +++ b/applications/tests/minunit.h @@ -76,8 +76,8 @@ extern "C" { #include "minunit_vars_ex.h" /* Test setup and teardown function pointers */ -static void (*minunit_setup)(void) = NULL; -static void (*minunit_teardown)(void) = NULL; +__attribute__((unused)) static void (*minunit_setup)(void) = NULL; +__attribute__((unused)) static void (*minunit_teardown)(void) = NULL; /* Definitions */ #define MU_TEST(method_name) static void method_name(void) @@ -457,7 +457,7 @@ static void (*minunit_teardown)(void) = NULL; * The returned real time is only useful for computing an elapsed time * between two calls to this function. */ -static double mu_timer_real(void) { +__attribute__((unused)) static double mu_timer_real(void) { #if defined(_WIN32) /* Windows 2000 and later. ---------------------------------- */ LARGE_INTEGER Time; @@ -529,7 +529,7 @@ static double mu_timer_real(void) { * Returns the amount of CPU time used by the current process, * in seconds, or -1.0 if an error occurred. */ -static double mu_timer_cpu(void) { +__attribute__((unused)) static double mu_timer_cpu(void) { #if defined(_WIN32) /* Windows -------------------------------------------------- */ FILETIME createTime; diff --git a/applications/tests/test_index.c b/applications/tests/test_index.c index fc459336..133259fb 100644 --- a/applications/tests/test_index.c +++ b/applications/tests/test_index.c @@ -18,26 +18,26 @@ void flipper_test_app(void* p) { GpioPin* blue_record = &blue; // configure pins - pinMode(red_record, GpioModeOutputOpenDrain); - pinMode(green_record, GpioModeOutputOpenDrain); - pinMode(blue_record, GpioModeOutputOpenDrain); + gpio_init(red_record, GpioModeOutputOpenDrain); + gpio_init(green_record, GpioModeOutputOpenDrain); + gpio_init(blue_record, GpioModeOutputOpenDrain); - digitalWrite(red_record, HIGH); - digitalWrite(green_record, HIGH); - digitalWrite(blue_record, LOW); + gpio_write(red_record, true); + gpio_write(green_record, true); + gpio_write(blue_record, false); uint32_t exitcode = run_minunit(); if(exitcode == 0) { // test passed - digitalWrite(red_record, HIGH); - digitalWrite(green_record, LOW); - digitalWrite(blue_record, HIGH); + gpio_write(red_record, true); + gpio_write(green_record, false); + gpio_write(blue_record, true); } else { // test failed - digitalWrite(red_record, LOW); - digitalWrite(green_record, HIGH); - digitalWrite(blue_record, HIGH); + gpio_write(red_record, false); + gpio_write(green_record, true); + gpio_write(blue_record, true); } set_exitcode(exitcode); diff --git a/core/api-basic/pubsub.h b/core/api-basic/pubsub.h index bc866a9f..1bd5bedc 100644 --- a/core/api-basic/pubsub.h +++ b/core/api-basic/pubsub.h @@ -12,7 +12,7 @@ and also subscriber can set `void*` context pointer that pass into callback (you can see callback signature below). */ -typedef void (*PubSubCallback)(void*, void*); +typedef void (*PubSubCallback)(const void*, void*); typedef struct PubSubType PubSub; typedef struct { diff --git a/core/api-hal/api-gpio.h b/core/api-hal/api-gpio.h index e9176393..6c424f0b 100644 --- a/core/api-hal/api-gpio.h +++ b/core/api-hal/api-gpio.h @@ -23,7 +23,7 @@ static inline void gpio_write(GpioPin* gpio, bool state) { } // read value from GPIO, false = LOW, true = HIGH -static inline bool gpio_read(GpioPin* gpio) { +static inline bool gpio_read(const GpioPin* gpio) { return hal_gpio_read(gpio); } diff --git a/core/flipper.h b/core/flipper.h index a1dc6659..a76f10eb 100644 --- a/core/flipper.h +++ b/core/flipper.h @@ -17,7 +17,6 @@ extern "C" { #endif #include -#include "flipper_arduino.h" void set_exitcode(uint32_t _exitcode); diff --git a/core/furi_ac.c b/core/furi_ac.c index d4d87a01..592b68b5 100644 --- a/core/furi_ac.c +++ b/core/furi_ac.c @@ -1,4 +1,5 @@ #include "flipper.h" +#include "api-hal-task.h" // TODO: this file contains printf, that not implemented on uC target diff --git a/firmware/Makefile b/firmware/Makefile index 1562c735..dafd3af6 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -1,6 +1,9 @@ PROJECT_ROOT = $(abspath $(dir $(abspath $(firstword $(MAKEFILE_LIST))))..) PROJECT = firmware +CFLAGS += -Werror +CPPFLAGS += -Werror + include $(PROJECT_ROOT)/make/base.mk include $(PROJECT_ROOT)/assets/assets.mk include $(PROJECT_ROOT)/core/core.mk diff --git a/firmware/targets/f2/Inc/usbd_conf.h b/firmware/targets/f2/Inc/usbd_conf.h index 272ad1e8..a16cd92f 100644 --- a/firmware/targets/f2/Inc/usbd_conf.h +++ b/firmware/targets/f2/Inc/usbd_conf.h @@ -36,7 +36,8 @@ #include "stm32l4xx_hal.h" /* USER CODE BEGIN INCLUDE */ - +void *USBD_static_malloc(uint32_t size); +void USBD_static_free(void* p); /* USER CODE END INCLUDE */ /** @addtogroup USBD_OTG_DRIVER diff --git a/firmware/targets/f2/Makefile b/firmware/targets/f2/Makefile deleted file mode 100644 index e0bc903b..00000000 --- a/firmware/targets/f2/Makefile +++ /dev/null @@ -1,285 +0,0 @@ -########################################################################################################################## -# File automatically-generated by tool: [projectgenerator] version: [3.10.0-B14] date: [Wed Oct 21 03:57:12 VLAT 2020] -########################################################################################################################## - -# ------------------------------------------------ -# Generic Makefile (based on gcc) -# -# ChangeLog : -# 2017-02-10 - Several enhancements + project update mode -# 2015-07-22 - first version -# ------------------------------------------------ - -###################################### -# target -###################################### -TARGET = cube - - -###################################### -# building variables -###################################### -# debug build? -DEBUG = 1 -# optimization -OPT = -Og - - -####################################### -# paths -####################################### -# Build path -BUILD_DIR = build - -###################################### -# source -###################################### -# C sources -C_SOURCES = \ -Src/main.c \ -Src/gpio.c \ -Src/freertos.c \ -Src/adc.c \ -Src/comp.c \ -Src/spi.c \ -Src/tim.c \ -Src/usart.c \ -Src/usb_device.c \ -Src/usbd_conf.c \ -Src/usbd_desc.c \ -Src/usbd_cdc_if.c \ -Src/stm32l4xx_it.c \ -Src/stm32l4xx_hal_msp.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pcd.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pcd_ex.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_usb.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_comp.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c \ -Src/system_stm32l4xx.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/croutine.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/event_groups.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/list.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/queue.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/tasks.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/timers.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c \ -/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c \ -Src/stm32l4xx_hal_timebase_tim.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pcd.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pcd_ex.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_ll_usb.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_adc_ex.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_comp.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/croutine.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/event_groups.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/list.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/queue.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/tasks.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/timers.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \ -C:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c - -# ASM sources -ASM_SOURCES = \ -startup_stm32l476xx.s - - -####################################### -# binaries -####################################### -PREFIX = arm-none-eabi- -# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx) -# either it can be added to the PATH environment variable. -ifdef GCC_PATH -CC = $(GCC_PATH)/$(PREFIX)gcc -AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp -CP = $(GCC_PATH)/$(PREFIX)objcopy -SZ = $(GCC_PATH)/$(PREFIX)size -else -CC = $(PREFIX)gcc -AS = $(PREFIX)gcc -x assembler-with-cpp -CP = $(PREFIX)objcopy -SZ = $(PREFIX)size -endif -HEX = $(CP) -O ihex -BIN = $(CP) -O binary -S - -####################################### -# CFLAGS -####################################### -# cpu -CPU = -mcpu=cortex-m4 - -# fpu -FPU = -mfpu=fpv4-sp-d16 - -# float-abi -FLOAT-ABI = -mfloat-abi=hard - -# mcu -MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) - -# macros for gcc -# AS defines -AS_DEFS = - -# C defines -C_DEFS = \ --DUSE_HAL_DRIVER \ --DSTM32L476xx - - -# AS includes -AS_INCLUDES = \ --IInc - -# C includes -C_INCLUDES = \ --IInc \ --I/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Inc \ --I/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Inc/Legacy \ --I/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/include \ --I/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 \ --I/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F \ --I/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/ST/STM32_USB_Device_Library/Core/Inc \ --I/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc \ --I/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/CMSIS/Device/ST/STM32L4xx/Include \ --I/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/CMSIS/Include \ --I/Users/aku/Work/flipper/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/CMSIS/Include \ --IC:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Inc \ --IC:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/STM32L4xx_HAL_Driver/Inc/Legacy \ --IC:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/include \ --IC:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 \ --IC:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F \ --IC:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/ST/STM32_USB_Device_Library/Core/Inc \ --IC:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc \ --IC:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/CMSIS/Device/ST/STM32L4xx/Include \ --IC:/work/cmake-stm32/projects/flipperzero-firmware-community/lib/STM32CubeL4/Drivers/CMSIS/Include - - -# compile gcc flags -ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections - -CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections - -ifeq ($(DEBUG), 1) -CFLAGS += -g -gdwarf-2 -endif - - -# Generate dependency information -CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" - - -####################################### -# LDFLAGS -####################################### -# link script -LDSCRIPT = STM32L476RGTx_FLASH.ld - -# libraries -LIBS = -lc -lm -lnosys -LIBDIR = -LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections - -# default action: build all -all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin - - -####################################### -# build the application -####################################### -# list of objects -OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) -vpath %.c $(sort $(dir $(C_SOURCES))) -# list of ASM program objects -OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) -vpath %.s $(sort $(dir $(ASM_SOURCES))) - -$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) - $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ - -$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) - $(AS) -c $(CFLAGS) $< -o $@ - -$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile - $(CC) $(OBJECTS) $(LDFLAGS) -o $@ - $(SZ) $@ - -$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR) - $(HEX) $< $@ - -$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR) - $(BIN) $< $@ - -$(BUILD_DIR): - mkdir $@ - -####################################### -# clean up -####################################### -clean: - -rm -fR $(BUILD_DIR) - -####################################### -# dependencies -####################################### --include $(wildcard $(BUILD_DIR)/*.d) - -# *** EOF *** diff --git a/firmware/targets/f2/Src/fatfs/spi_sd_hal.c b/firmware/targets/f2/Src/fatfs/spi_sd_hal.c index 832431bd..8b6ae579 100644 --- a/firmware/targets/f2/Src/fatfs/spi_sd_hal.c +++ b/firmware/targets/f2/Src/fatfs/spi_sd_hal.c @@ -51,7 +51,7 @@ static void SPIx_WriteReadData(const uint8_t* DataIn, uint8_t* DataOut, uint16_t * @param Value: value to be written * @retval None */ -static void SPIx_Write(uint8_t Value) { +__attribute__((unused)) static void SPIx_Write(uint8_t Value) { HAL_StatusTypeDef status = HAL_OK; uint8_t data; diff --git a/firmware/targets/f2/Src/hacks.c b/firmware/targets/f2/Src/hacks.c deleted file mode 100644 index 8fa6665f..00000000 --- a/firmware/targets/f2/Src/hacks.c +++ /dev/null @@ -1,7 +0,0 @@ -#include -#include - -bool task_equal(TaskHandle_t a, TaskHandle_t b) { - if(a == NULL || b == NULL) return false; - return a == b; -} diff --git a/firmware/targets/f2/api-hal/api-hal-delay.c b/firmware/targets/f2/api-hal/api-hal-delay.c index 53db1fb0..bda9cace 100644 --- a/firmware/targets/f2/api-hal/api-hal-delay.c +++ b/firmware/targets/f2/api-hal/api-hal-delay.c @@ -1,4 +1,6 @@ #include "api-hal-delay.h" +#include "assert.h" +#include "cmsis_os2.h" void delay_us_init_DWT(void) { CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; @@ -6,9 +8,17 @@ void delay_us_init_DWT(void) { DWT->CYCCNT = 0U; } -void delay_us(float time) { +void delay_us(float microseconds) { uint32_t start = DWT->CYCCNT; - uint32_t time_ticks = time * (SystemCoreClock / 1000000); + uint32_t time_ticks = microseconds * (SystemCoreClock / 1000000.0f); while((DWT->CYCCNT - start) < time_ticks) { }; +} + +// cannot be used in ISR +// TODO add delay_ISR variant +void delay(float milliseconds) { + uint32_t ticks = milliseconds / (1000.0f / osKernelGetTickFreq()); + osStatus_t result = osDelay(ticks); + assert(result == osOK); } \ No newline at end of file diff --git a/firmware/targets/f2/api-hal/api-hal-delay.h b/firmware/targets/f2/api-hal/api-hal-delay.h index 4df5cd4b..9ab51e24 100644 --- a/firmware/targets/f2/api-hal/api-hal-delay.h +++ b/firmware/targets/f2/api-hal/api-hal-delay.h @@ -1,5 +1,6 @@ #pragma once #include "main.h" -void delay_us(float time); -void delay_us_init_DWT(void); \ No newline at end of file +void delay(float milliseconds); +void delay_us(float microseconds); +void delay_us_init_DWT(void); diff --git a/firmware/targets/f2/api-hal/api-hal-gpio.h b/firmware/targets/f2/api-hal/api-hal-gpio.h index e31b63f9..b125a445 100644 --- a/firmware/targets/f2/api-hal/api-hal-gpio.h +++ b/firmware/targets/f2/api-hal/api-hal-gpio.h @@ -52,7 +52,7 @@ static inline void hal_gpio_write(GpioPin* gpio, bool state) { } // read value from GPIO, false = LOW, true = HIGH -static inline bool hal_gpio_read(GpioPin* gpio) { +static inline bool hal_gpio_read(const GpioPin* gpio) { if((gpio->port->IDR & gpio->pin) != 0x00U) { return true; } else { diff --git a/firmware/targets/f2/api-hal/api-hal-task.c b/firmware/targets/f2/api-hal/api-hal-task.c index c6127d65..263bc797 100644 --- a/firmware/targets/f2/api-hal/api-hal-task.c +++ b/firmware/targets/f2/api-hal/api-hal-task.c @@ -1,5 +1,5 @@ -#include "api-hal-task.h" #include "cmsis_os.h" +#include "api-hal-task.h" //-----------------------------cmsis_os2.c------------------------------- // helpers to get isr context @@ -51,4 +51,9 @@ bool task_is_isr_context(void) { return IS_IRQ(); +} + +bool task_equal(TaskHandle_t a, TaskHandle_t b) { + if(a == NULL || b == NULL) return false; + return a == b; } \ No newline at end of file diff --git a/firmware/targets/f2/api-hal/api-hal-task.h b/firmware/targets/f2/api-hal/api-hal-task.h index 87ee5ae7..f1d015cb 100644 --- a/firmware/targets/f2/api-hal/api-hal-task.h +++ b/firmware/targets/f2/api-hal/api-hal-task.h @@ -1,5 +1,7 @@ #pragma once #include "main.h" +#include #include -bool task_is_isr_context(void); \ No newline at end of file +bool task_equal(TaskHandle_t a, TaskHandle_t b); +bool task_is_isr_context(void); diff --git a/firmware/targets/local/Inc/cmsis_os.h b/firmware/targets/local/Inc/cmsis_os.h index 0fa7ef68..12019bf8 100644 --- a/firmware/targets/local/Inc/cmsis_os.h +++ b/firmware/targets/local/Inc/cmsis_os.h @@ -47,7 +47,6 @@ TaskHandle_t xTaskCreateStatic(TaskFunction_t pxTaskCode, void vTaskDelete(TaskHandle_t xTask); TaskHandle_t xTaskGetCurrentTaskHandle(void); SemaphoreHandle_t xSemaphoreCreateMutexStatic(StaticSemaphore_t* pxMutexBuffer); -bool task_equal(TaskHandle_t a, TaskHandle_t b); QueueHandle_t xQueueCreateStatic(UBaseType_t uxQueueLength, UBaseType_t uxItemSize, diff --git a/firmware/targets/local/Src/lo_hal.c b/firmware/targets/local/Src/lo_hal.c index 6b13ee82..b1d3106d 100644 --- a/firmware/targets/local/Src/lo_hal.c +++ b/firmware/targets/local/Src/lo_hal.c @@ -16,4 +16,6 @@ HAL_UART_Transmit(UART_HandleTypeDef* handle, uint8_t* bufer, uint16_t size, uin return res; } -void BSP_SD_Init() {} +uint8_t BSP_SD_Init() { + return 0; +} diff --git a/firmware/targets/local/Src/lo_os.c b/firmware/targets/local/Src/lo_os.c index 6b0440eb..7a8e51ea 100644 --- a/firmware/targets/local/Src/lo_os.c +++ b/firmware/targets/local/Src/lo_os.c @@ -74,12 +74,6 @@ TaskHandle_t xTaskGetCurrentTaskHandle(void) { return thread; } -bool task_equal(TaskHandle_t a, TaskHandle_t b) { - if(a == NULL || b == NULL) return false; - - return pthread_equal(*a, *b) != 0; -} - BaseType_t xQueueSend(QueueHandle_t xQueue, const void* pvItemToQueue, TickType_t xTicksToWait) { // TODO: add implementation return pdTRUE; @@ -269,11 +263,11 @@ osStatus_t osMutexDelete (osMutexId_t mutex_id) { osSemaphoreId_t osSemaphoreNew(uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr) { if(max_count != 1) { // Non-binary semaphors are not supported at the moment - return osErrorParameter; + return NULL; } if(attr != NULL) { // Attributes are not supported at the moment - return osErrorParameter; + return NULL; } SemaphoreHandle_t handle = osMutexNew(NULL); diff --git a/firmware/targets/local/api-hal/api-hal-delay.c b/firmware/targets/local/api-hal/api-hal-delay.c index e40d084f..b9cfb36c 100644 --- a/firmware/targets/local/api-hal/api-hal-delay.c +++ b/firmware/targets/local/api-hal/api-hal-delay.c @@ -1,7 +1,11 @@ #include "api-hal-delay.h" #include +#include -void delay_us(uint32_t time) { - // How to deal with it - printf("[DELAY] %d us\n", time); +void delay_us(float microseconds) { + usleep(microseconds); +} + +void delay(float milliseconds) { + usleep(milliseconds * 1000); } \ No newline at end of file diff --git a/firmware/targets/local/api-hal/api-hal-delay.h b/firmware/targets/local/api-hal/api-hal-delay.h index 9db6e3a8..ff69ce4b 100644 --- a/firmware/targets/local/api-hal/api-hal-delay.h +++ b/firmware/targets/local/api-hal/api-hal-delay.h @@ -1,4 +1,6 @@ #pragma once #include "main.h" -void delay_us(uint32_t time); \ No newline at end of file +void delay_us(float microseconds); + +void delay(float milliseconds); \ No newline at end of file diff --git a/firmware/targets/local/api-hal/api-hal-gpio.c b/firmware/targets/local/api-hal/api-hal-gpio.c index 13124ace..69e8e4f8 100644 --- a/firmware/targets/local/api-hal/api-hal-gpio.c +++ b/firmware/targets/local/api-hal/api-hal-gpio.c @@ -41,7 +41,7 @@ void hal_gpio_write(GpioPin* gpio, bool state){ } // read value from GPIO, false = LOW, true = HIGH -bool hal_gpio_read(GpioPin* gpio){ +bool hal_gpio_read(const GpioPin* gpio){ // TODO emulate pin state? return false; } diff --git a/firmware/targets/local/api-hal/api-hal-gpio.h b/firmware/targets/local/api-hal/api-hal-gpio.h index e6dd4856..75872856 100644 --- a/firmware/targets/local/api-hal/api-hal-gpio.h +++ b/firmware/targets/local/api-hal/api-hal-gpio.h @@ -46,4 +46,4 @@ void hal_gpio_init(GpioPin* gpio, GpioMode mode, GpioPull pull, GpioSpeed speed) void hal_gpio_write(GpioPin* gpio, bool state); // read value from GPIO, false = LOW, true = HIGH -bool hal_gpio_read(GpioPin* gpio); \ No newline at end of file +bool hal_gpio_read(const GpioPin* gpio); \ No newline at end of file diff --git a/firmware/targets/local/api-hal/api-hal-task.c b/firmware/targets/local/api-hal/api-hal-task.c index 9729cedd..f3d5f8d1 100644 --- a/firmware/targets/local/api-hal/api-hal-task.c +++ b/firmware/targets/local/api-hal/api-hal-task.c @@ -1,5 +1,14 @@ #include "api-hal-task.h" +bool task_equal(TaskHandle_t a, TaskHandle_t b) { + if(a == NULL || b == NULL) return false; + return pthread_equal(*a, *b) != 0; +} + bool task_is_isr_context(void) { return false; -} \ No newline at end of file +} + +void taskDISABLE_INTERRUPTS(void){ + // we cant disable main os sheduler +}; diff --git a/firmware/targets/local/api-hal/api-hal-task.h b/firmware/targets/local/api-hal/api-hal-task.h index 87ee5ae7..8aed7f0f 100644 --- a/firmware/targets/local/api-hal/api-hal-task.h +++ b/firmware/targets/local/api-hal/api-hal-task.h @@ -1,5 +1,8 @@ #pragma once #include "main.h" +#include #include -bool task_is_isr_context(void); \ No newline at end of file +bool task_equal(TaskHandle_t a, TaskHandle_t b); +bool task_is_isr_context(void); +__attribute__((unused)) void taskDISABLE_INTERRUPTS(void);