Core code cleanup (#206)
* add delay function * todo about delay_isr * remove arduino defines and fix all apps to use core-api/hal-api * delay for local target * remove warnings of task_equal * fix BSP_SD_Init * fix USBD_static * grio read constant pointer to gpio * add TODO about ISR context * const void* arg for pubsub api * mark unused functions * app pointers now pointed to constant apps * fix printf format * fix "unused" warnings in local target * fix const pin read in local target * fix int to pointer warnings in local target * power read mutex error fix * delete old makefile * add -werror Co-authored-by: Aleksandr Kutuzov <aku@plooks.com> Co-authored-by: aanper <mail@s3f.ru>
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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<<CPOL) | (1 << CPHA)       3
 | 
			
		||||
*OUTPUT       :none
 | 
			
		||||
******************************************************************************/
 | 
			
		||||
void CC1101::SpiMode(byte config) {
 | 
			
		||||
void CC1101::SpiMode(uint8_t config) {
 | 
			
		||||
    /*
 | 
			
		||||
  byte tmp;
 | 
			
		||||
  uint8_t tmp;
 | 
			
		||||
  // enable SPI master with configuration byte specified
 | 
			
		||||
  SPCR = 0;
 | 
			
		||||
  SPCR = (config & 0x7F) | (1<<SPE) | (1<<MSTR);
 | 
			
		||||
@@ -95,7 +95,7 @@ void CC1101::SpiMode(byte config) {
 | 
			
		||||
*INPUT        :value: data to send
 | 
			
		||||
*OUTPUT       :data to receive
 | 
			
		||||
****************************************************************/
 | 
			
		||||
byte CC1101::SpiTransfer(byte value) {
 | 
			
		||||
uint8_t CC1101::SpiTransfer(uint8_t value) {
 | 
			
		||||
    uint8_t buf[1] = {value};
 | 
			
		||||
    uint8_t rxbuf[1] = {0};
 | 
			
		||||
 | 
			
		||||
@@ -110,13 +110,13 @@ byte CC1101::SpiTransfer(byte value) {
 | 
			
		||||
*INPUT        :addr: register address; value: register value
 | 
			
		||||
*OUTPUT       :none
 | 
			
		||||
****************************************************************/
 | 
			
		||||
void CC1101::SpiWriteReg(byte addr, byte value) {
 | 
			
		||||
    digitalWrite(ss_pin, LOW);
 | 
			
		||||
    while(digitalRead(this->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
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -3,6 +3,8 @@
 | 
			
		||||
#include "flipper_v2.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
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) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,16 @@
 | 
			
		||||
#include "flipper_v2.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
 | 
			
		||||
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) {
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,8 @@
 | 
			
		||||
#include <rfal_nfc.h>
 | 
			
		||||
#include <rfal_nfca.h>
 | 
			
		||||
 | 
			
		||||
#include <st25r3916_irq.h>
 | 
			
		||||
 | 
			
		||||
#include "dispatcher.h"
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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));
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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;
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user