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:
		
							parent
							
								
									f9b6440f7f
								
							
						
					
					
						commit
						979af6c165
					
				@ -7,12 +7,12 @@
 | 
				
			|||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
    FuriApp* handler;
 | 
					    FuriApp* handler;
 | 
				
			||||||
    Widget* widget;
 | 
					    Widget* widget;
 | 
				
			||||||
    FlipperStartupApp* current_app;
 | 
					    const FlipperStartupApp* current_app;
 | 
				
			||||||
} AppLoaderState;
 | 
					} AppLoaderState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
    AppLoaderState* state;
 | 
					    AppLoaderState* state;
 | 
				
			||||||
    FlipperStartupApp* app;
 | 
					    const FlipperStartupApp* app;
 | 
				
			||||||
} AppLoaderContext;
 | 
					} AppLoaderContext;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO add mutex for contex
 | 
					// 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) {
 | 
					int16_t rx_rssi(CC1101* cc1101, const FreqConfig* config) {
 | 
				
			||||||
    cc1101->SetReceive();
 | 
					    cc1101->SetReceive();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    delayMicroseconds(RSSI_DELAY);
 | 
					    delay_us(RSSI_DELAY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // 1.4.8) read PKTSTATUS register while the radio is in RX state
 | 
					    // 1.4.8) read PKTSTATUS register while the radio is in RX state
 | 
				
			||||||
    /*uint8_t _pkt_status = */ cc1101->SpiReadStatus(CC1101_PKTSTATUS);
 | 
					    /*uint8_t _pkt_status = */ cc1101->SpiReadStatus(CC1101_PKTSTATUS);
 | 
				
			||||||
@ -262,7 +262,7 @@ extern "C" void cc1101_workaround(void* p) {
 | 
				
			|||||||
    GpioPin* led_record = &led;
 | 
					    GpioPin* led_record = &led;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // configure pin
 | 
					    // configure pin
 | 
				
			||||||
    pinMode(led_record, GpioModeOutputOpenDrain);
 | 
					    gpio_init(led_record, GpioModeOutputOpenDrain);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const int16_t RSSI_THRESHOLD = -89;
 | 
					    const int16_t RSSI_THRESHOLD = -89;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -327,9 +327,9 @@ extern "C" void cc1101_workaround(void* p) {
 | 
				
			|||||||
            state->need_cc1101_conf = false;
 | 
					            state->need_cc1101_conf = false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        digitalWrite(
 | 
					        gpio_write(
 | 
				
			||||||
            led_record,
 | 
					            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);
 | 
					        release_mutex(&state_mutex, state);
 | 
				
			||||||
        widget_update(widget);
 | 
					        widget_update(widget);
 | 
				
			||||||
 | 
				
			|||||||
@ -17,7 +17,7 @@ CC1101::CC1101(GpioPin* ss_pin) {
 | 
				
			|||||||
    pinMode(gdo0_pin, OUTPUT); //GDO0 as asynchronous serial mode input
 | 
					    pinMode(gdo0_pin, OUTPUT); //GDO0 as asynchronous serial mode input
 | 
				
			||||||
    pinMode(gdo2_pin, INPUT); //GDO2 as asynchronous serial mode output
 | 
					    pinMode(gdo2_pin, INPUT); //GDO2 as asynchronous serial mode output
 | 
				
			||||||
    */
 | 
					    */
 | 
				
			||||||
    pinMode(ss_pin, OUTPUT);
 | 
					    gpio_init(ss_pin, GpioModeOutputPushPull);
 | 
				
			||||||
    this->ss_pin = ss_pin;
 | 
					    this->ss_pin = ss_pin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // TODO open record
 | 
					    // TODO open record
 | 
				
			||||||
@ -79,9 +79,9 @@ Function: SpiMode
 | 
				
			|||||||
               (1<<CPOL) | (1 << CPHA)       3
 | 
					               (1<<CPOL) | (1 << CPHA)       3
 | 
				
			||||||
*OUTPUT       :none
 | 
					*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
 | 
					  // enable SPI master with configuration byte specified
 | 
				
			||||||
  SPCR = 0;
 | 
					  SPCR = 0;
 | 
				
			||||||
  SPCR = (config & 0x7F) | (1<<SPE) | (1<<MSTR);
 | 
					  SPCR = (config & 0x7F) | (1<<SPE) | (1<<MSTR);
 | 
				
			||||||
@ -95,7 +95,7 @@ void CC1101::SpiMode(byte config) {
 | 
				
			|||||||
*INPUT        :value: data to send
 | 
					*INPUT        :value: data to send
 | 
				
			||||||
*OUTPUT       :data to receive
 | 
					*OUTPUT       :data to receive
 | 
				
			||||||
****************************************************************/
 | 
					****************************************************************/
 | 
				
			||||||
byte CC1101::SpiTransfer(byte value) {
 | 
					uint8_t CC1101::SpiTransfer(uint8_t value) {
 | 
				
			||||||
    uint8_t buf[1] = {value};
 | 
					    uint8_t buf[1] = {value};
 | 
				
			||||||
    uint8_t rxbuf[1] = {0};
 | 
					    uint8_t rxbuf[1] = {0};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -110,13 +110,13 @@ byte CC1101::SpiTransfer(byte value) {
 | 
				
			|||||||
*INPUT        :addr: register address; value: register value
 | 
					*INPUT        :addr: register address; value: register value
 | 
				
			||||||
*OUTPUT       :none
 | 
					*OUTPUT       :none
 | 
				
			||||||
****************************************************************/
 | 
					****************************************************************/
 | 
				
			||||||
void CC1101::SpiWriteReg(byte addr, byte value) {
 | 
					void CC1101::SpiWriteReg(uint8_t addr, uint8_t value) {
 | 
				
			||||||
    digitalWrite(ss_pin, LOW);
 | 
					    gpio_write(ss_pin, false);
 | 
				
			||||||
    while(digitalRead(this->miso_pin_record))
 | 
					    while(gpio_read(this->miso_pin_record))
 | 
				
			||||||
        ;
 | 
					        ;
 | 
				
			||||||
    SpiTransfer(addr);
 | 
					    SpiTransfer(addr);
 | 
				
			||||||
    SpiTransfer(value);
 | 
					    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
 | 
					*INPUT        :addr: register address; buffer:register value array; num:number to write
 | 
				
			||||||
*OUTPUT       :none
 | 
					*OUTPUT       :none
 | 
				
			||||||
****************************************************************/
 | 
					****************************************************************/
 | 
				
			||||||
void CC1101::SpiWriteBurstReg(byte addr, byte* buffer, byte num) {
 | 
					void CC1101::SpiWriteBurstReg(uint8_t addr, uint8_t* buffer, uint8_t num) {
 | 
				
			||||||
    byte i, temp;
 | 
					    uint8_t i, temp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    temp = addr | WRITE_BURST;
 | 
					    temp = addr | WRITE_BURST;
 | 
				
			||||||
    digitalWrite(ss_pin, LOW);
 | 
					    gpio_write(ss_pin, false);
 | 
				
			||||||
    while(digitalRead(this->miso_pin_record))
 | 
					    while(gpio_read(this->miso_pin_record))
 | 
				
			||||||
        ;
 | 
					        ;
 | 
				
			||||||
    SpiTransfer(temp);
 | 
					    SpiTransfer(temp);
 | 
				
			||||||
    for(i = 0; i < num; i++) {
 | 
					    for(i = 0; i < num; i++) {
 | 
				
			||||||
        SpiTransfer(buffer[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//
 | 
					*INPUT        :strobe: command; //refer define in CC1101.h//
 | 
				
			||||||
*OUTPUT       :none
 | 
					*OUTPUT       :none
 | 
				
			||||||
****************************************************************/
 | 
					****************************************************************/
 | 
				
			||||||
void CC1101::SpiStrobe(byte strobe) {
 | 
					void CC1101::SpiStrobe(uint8_t strobe) {
 | 
				
			||||||
    digitalWrite(ss_pin, LOW);
 | 
					    gpio_write(ss_pin, false);
 | 
				
			||||||
    while(digitalRead(this->miso_pin_record))
 | 
					    while(gpio_read(this->miso_pin_record))
 | 
				
			||||||
        ;
 | 
					        ;
 | 
				
			||||||
    SpiTransfer(strobe);
 | 
					    SpiTransfer(strobe);
 | 
				
			||||||
    digitalWrite(ss_pin, HIGH);
 | 
					    gpio_write(ss_pin, true);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/****************************************************************
 | 
					/****************************************************************
 | 
				
			||||||
@ -159,16 +159,16 @@ void CC1101::SpiStrobe(byte strobe) {
 | 
				
			|||||||
*INPUT        :addr: register address
 | 
					*INPUT        :addr: register address
 | 
				
			||||||
*OUTPUT       :register value
 | 
					*OUTPUT       :register value
 | 
				
			||||||
****************************************************************/
 | 
					****************************************************************/
 | 
				
			||||||
byte CC1101::SpiReadReg(byte addr) {
 | 
					uint8_t CC1101::SpiReadReg(uint8_t addr) {
 | 
				
			||||||
    byte temp, value;
 | 
					    uint8_t temp, value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    temp = addr | READ_SINGLE;
 | 
					    temp = addr | READ_SINGLE;
 | 
				
			||||||
    digitalWrite(ss_pin, LOW);
 | 
					    gpio_write(ss_pin, false);
 | 
				
			||||||
    while(digitalRead(this->miso_pin_record))
 | 
					    while(gpio_read(this->miso_pin_record))
 | 
				
			||||||
        ;
 | 
					        ;
 | 
				
			||||||
    SpiTransfer(temp);
 | 
					    SpiTransfer(temp);
 | 
				
			||||||
    value = SpiTransfer(0);
 | 
					    value = SpiTransfer(0);
 | 
				
			||||||
    digitalWrite(ss_pin, HIGH);
 | 
					    gpio_write(ss_pin, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return value;
 | 
					    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
 | 
					*INPUT        :addr: register address; buffer:array to store register value; num: number to read
 | 
				
			||||||
*OUTPUT       :none
 | 
					*OUTPUT       :none
 | 
				
			||||||
****************************************************************/
 | 
					****************************************************************/
 | 
				
			||||||
void CC1101::SpiReadBurstReg(byte addr, byte* buffer, byte num) {
 | 
					void CC1101::SpiReadBurstReg(uint8_t addr, uint8_t* buffer, uint8_t num) {
 | 
				
			||||||
    byte i, temp;
 | 
					    uint8_t i, temp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    temp = addr | READ_BURST;
 | 
					    temp = addr | READ_BURST;
 | 
				
			||||||
    digitalWrite(ss_pin, LOW);
 | 
					    gpio_write(ss_pin, false);
 | 
				
			||||||
    while(digitalRead(this->miso_pin_record))
 | 
					    while(gpio_read(this->miso_pin_record))
 | 
				
			||||||
        ;
 | 
					        ;
 | 
				
			||||||
    SpiTransfer(temp);
 | 
					    SpiTransfer(temp);
 | 
				
			||||||
    for(i = 0; i < num; i++) {
 | 
					    for(i = 0; i < num; i++) {
 | 
				
			||||||
        buffer[i] = SpiTransfer(0);
 | 
					        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
 | 
					*INPUT        :addr: register address
 | 
				
			||||||
*OUTPUT       :status value
 | 
					*OUTPUT       :status value
 | 
				
			||||||
****************************************************************/
 | 
					****************************************************************/
 | 
				
			||||||
byte CC1101::SpiReadStatus(byte addr) {
 | 
					uint8_t CC1101::SpiReadStatus(uint8_t addr) {
 | 
				
			||||||
    byte value, temp;
 | 
					    uint8_t value, temp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    temp = addr | READ_BURST;
 | 
					    temp = addr | READ_BURST;
 | 
				
			||||||
    digitalWrite(ss_pin, LOW);
 | 
					    gpio_write(ss_pin, false);
 | 
				
			||||||
    while(digitalRead(this->miso_pin_record))
 | 
					    while(gpio_read(this->miso_pin_record))
 | 
				
			||||||
        ;
 | 
					        ;
 | 
				
			||||||
    SpiTransfer(temp);
 | 
					    SpiTransfer(temp);
 | 
				
			||||||
    value = SpiTransfer(0);
 | 
					    value = SpiTransfer(0);
 | 
				
			||||||
    digitalWrite(ss_pin, HIGH);
 | 
					    gpio_write(ss_pin, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return value;
 | 
					    return value;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -220,17 +220,17 @@ byte CC1101::SpiReadStatus(byte addr) {
 | 
				
			|||||||
*OUTPUT       :none
 | 
					*OUTPUT       :none
 | 
				
			||||||
****************************************************************/
 | 
					****************************************************************/
 | 
				
			||||||
void CC1101::Reset(void) {
 | 
					void CC1101::Reset(void) {
 | 
				
			||||||
    digitalWrite(ss_pin, LOW);
 | 
					    gpio_write(ss_pin, false);
 | 
				
			||||||
    delay(1);
 | 
					    delay(1);
 | 
				
			||||||
    digitalWrite(ss_pin, HIGH);
 | 
					    gpio_write(ss_pin, true);
 | 
				
			||||||
    delay(1);
 | 
					    delay(1);
 | 
				
			||||||
    digitalWrite(ss_pin, LOW);
 | 
					    gpio_write(ss_pin, false);
 | 
				
			||||||
    while(digitalRead(this->miso_pin_record))
 | 
					    while(gpio_read(this->miso_pin_record))
 | 
				
			||||||
        ;
 | 
					        ;
 | 
				
			||||||
    SpiTransfer(CC1101_SRES);
 | 
					    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
 | 
					*FUNCTION NAME:Init
 | 
				
			||||||
@ -238,20 +238,21 @@ void CC1101::Reset(void) {
 | 
				
			|||||||
*INPUT        :none
 | 
					*INPUT        :none
 | 
				
			||||||
*OUTPUT       :none
 | 
					*OUTPUT       :none
 | 
				
			||||||
****************************************************************/
 | 
					****************************************************************/
 | 
				
			||||||
byte CC1101::Init(void) {
 | 
					uint8_t CC1101::Init(void) {
 | 
				
			||||||
#ifdef CC1101_DEBUG
 | 
					#ifdef CC1101_DEBUG
 | 
				
			||||||
    printf("Init SPI...\n");
 | 
					    printf("Init SPI...\n");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    SpiInit(); //spi initialization
 | 
					    SpiInit(); //spi initialization
 | 
				
			||||||
    digitalWrite(ss_pin, HIGH);
 | 
					    gpio_write(ss_pin, true);
 | 
				
			||||||
// digitalWrite(SCK_PIN, HIGH);
 | 
					// gpio_write(SCK_PIN, true);
 | 
				
			||||||
// digitalWrite(MOSI_PIN, LOW);
 | 
					// gpio_write(MOSI_PIN, false);
 | 
				
			||||||
#ifdef CC1101_DEBUG
 | 
					#ifdef CC1101_DEBUG
 | 
				
			||||||
    printf("Reset CC1101...\n");
 | 
					    printf("Reset CC1101...\n");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    Reset(); //CC1101 reset
 | 
					    Reset(); //CC1101 reset
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    byte partnum, version;
 | 
					    uint8_t partnum __attribute__((unused));
 | 
				
			||||||
 | 
					    uint8_t version;
 | 
				
			||||||
    partnum = SpiReadStatus(CC1101_PARTNUM);
 | 
					    partnum = SpiReadStatus(CC1101_PARTNUM);
 | 
				
			||||||
    version = SpiReadStatus(CC1101_VERSION);
 | 
					    version = SpiReadStatus(CC1101_VERSION);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -277,15 +278,15 @@ byte CC1101::Init(void) {
 | 
				
			|||||||
*INPUT        :byte mode
 | 
					*INPUT        :byte mode
 | 
				
			||||||
*OUTPUT       :none
 | 
					*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
 | 
					    SpiWriteReg(CC1101_MDMCFG2, mode); //no sync/preamble; ASK/OOK only support up to -1dbm
 | 
				
			||||||
    if((mode | 0x30) == ASK) {
 | 
					    if((mode | 0x30) == ASK) {
 | 
				
			||||||
        SpiWriteReg(CC1101_FREND0, 0x11); //use first up to PATABLE(0)
 | 
					        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
 | 
					        SpiWriteBurstReg(CC1101_PATABLE, PaTabel, 8); //CC1101 PATABLE config
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        SpiWriteReg(CC1101_FREND0, 0x10); //use first up to PATABLE(0)
 | 
					        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
 | 
					        SpiWriteBurstReg(CC1101_PATABLE, PaTabel, 8); //CC1101 PATABLE config
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -377,7 +378,7 @@ void CC1101::RegConfigSettings(void) {
 | 
				
			|||||||
 *INPUT        :Freq2, Freq1, Freq0
 | 
					 *INPUT        :Freq2, Freq1, Freq0
 | 
				
			||||||
 *OUTPUT       :none
 | 
					 *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_FREQ2, freq2);
 | 
				
			||||||
    SpiWriteReg(CC1101_FREQ1, freq1);
 | 
					    SpiWriteReg(CC1101_FREQ1, freq1);
 | 
				
			||||||
    SpiWriteReg(CC1101_FREQ0, freq0);
 | 
					    SpiWriteReg(CC1101_FREQ0, freq0);
 | 
				
			||||||
@ -392,7 +393,7 @@ void CC1101::SetChannel(int channel) {
 | 
				
			|||||||
#ifdef CC1101_DEBUG
 | 
					#ifdef CC1101_DEBUG
 | 
				
			||||||
    printf("Set CC1101 channel to: %d \n", channel);
 | 
					    printf("Set CC1101 channel to: %d \n", channel);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    SpiWriteReg(CC1101_CHANNR, (byte)channel); //related to channel numbers
 | 
					    SpiWriteReg(CC1101_CHANNR, (uint8_t)channel); //related to channel numbers
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/****************************************************************
 | 
					/****************************************************************
 | 
				
			||||||
 *FUNCTION NAME:SetReceive
 | 
					 *FUNCTION NAME:SetReceive
 | 
				
			||||||
 | 
				
			|||||||
@ -143,25 +143,25 @@ private:
 | 
				
			|||||||
    GpioPin* gdo2_pin;
 | 
					    GpioPin* gdo2_pin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    void SpiMode(byte config);
 | 
					    void SpiMode(uint8_t config);
 | 
				
			||||||
    byte SpiTransfer(byte value);
 | 
					    uint8_t SpiTransfer(uint8_t value);
 | 
				
			||||||
    void Reset(void);
 | 
					    void Reset(void);
 | 
				
			||||||
    void SpiWriteBurstReg(byte addr, byte* buffer, byte num);
 | 
					    void SpiWriteBurstReg(uint8_t addr, uint8_t* buffer, uint8_t num);
 | 
				
			||||||
    byte SpiReadReg(byte addr);
 | 
					    uint8_t SpiReadReg(uint8_t addr);
 | 
				
			||||||
    void SpiReadBurstReg(byte addr, byte* buffer, byte num);
 | 
					    void SpiReadBurstReg(uint8_t addr, uint8_t* buffer, uint8_t num);
 | 
				
			||||||
    void RegConfigSettings(void);
 | 
					    void RegConfigSettings(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    CC1101(GpioPin* ss_pin);
 | 
					    CC1101(GpioPin* ss_pin);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void SpiWriteReg(byte addr, byte value);
 | 
					    void SpiWriteReg(uint8_t addr, uint8_t value);
 | 
				
			||||||
    void SpiInit(void);
 | 
					    void SpiInit(void);
 | 
				
			||||||
    void SpiEnd(void);
 | 
					    void SpiEnd(void);
 | 
				
			||||||
    void SetMod(byte mode);
 | 
					    void SetMod(uint8_t mode);
 | 
				
			||||||
    void SetFreq(byte Freq2, byte Freq1, byte Freq0);
 | 
					    void SetFreq(uint8_t Freq2, uint8_t Freq1, uint8_t Freq0);
 | 
				
			||||||
    byte Init(void);
 | 
					    uint8_t Init(void);
 | 
				
			||||||
    void SpiStrobe(byte strobe);
 | 
					    void SpiStrobe(uint8_t strobe);
 | 
				
			||||||
    byte SpiReadStatus(byte addr);
 | 
					    uint8_t SpiReadStatus(uint8_t addr);
 | 
				
			||||||
    void SetReceive(void);
 | 
					    void SetReceive(void);
 | 
				
			||||||
    void SetTransmit(void);
 | 
					    void SetTransmit(void);
 | 
				
			||||||
    void SetChannel(int channel);
 | 
					    void SetChannel(int channel);
 | 
				
			||||||
 | 
				
			|||||||
@ -9,12 +9,12 @@ void application_blink(void* p) {
 | 
				
			|||||||
    GpioPin* led_record = &led;
 | 
					    GpioPin* led_record = &led;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // configure pin
 | 
					    // configure pin
 | 
				
			||||||
    pinMode(led_record, GpioModeOutputOpenDrain);
 | 
					    gpio_init(led_record, GpioModeOutputOpenDrain);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    while(1) {
 | 
					    while(1) {
 | 
				
			||||||
        digitalWrite(led_record, HIGH);
 | 
					        gpio_write(led_record, true);
 | 
				
			||||||
        delay(500);
 | 
					        delay(500);
 | 
				
			||||||
        digitalWrite(led_record, LOW);
 | 
					        gpio_write(led_record, false);
 | 
				
			||||||
        delay(500);
 | 
					        delay(500);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -3,6 +3,8 @@
 | 
				
			|||||||
#include "flipper_v2.h"
 | 
					#include "flipper_v2.h"
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern uint8_t BSP_SD_Init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO currently we have small stack, so it will be static
 | 
					// TODO currently we have small stack, so it will be static
 | 
				
			||||||
FuriRecordSubscriber* furi_log;
 | 
					FuriRecordSubscriber* furi_log;
 | 
				
			||||||
#define STR_BUFFER_SIZE 128
 | 
					#define STR_BUFFER_SIZE 128
 | 
				
			||||||
@ -72,8 +74,6 @@ void fatfs_list(void* p) {
 | 
				
			|||||||
    u8g2_ClearBuffer(fb);
 | 
					    u8g2_ClearBuffer(fb);
 | 
				
			||||||
    furi_commit(fb_record);
 | 
					    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();
 | 
					    bsp_result = BSP_SD_Init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(bsp_result != 0) {
 | 
					    if(bsp_result != 0) {
 | 
				
			||||||
 | 
				
			|||||||
@ -1,10 +1,16 @@
 | 
				
			|||||||
#include "flipper_v2.h"
 | 
					#include "flipper_v2.h"
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void state_cb(const void* value, void* ctx) {
 | 
					typedef union {
 | 
				
			||||||
    const InputState* state = value;
 | 
					    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) {
 | 
					static void event_cb(const void* value, void* ctx) {
 | 
				
			||||||
 | 
				
			|||||||
@ -9,7 +9,7 @@ void application_uart_write(void* p) {
 | 
				
			|||||||
    // TODO open record
 | 
					    // TODO open record
 | 
				
			||||||
    GpioPin* led_record = &led;
 | 
					    GpioPin* led_record = &led;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pinMode(led_record, GpioModeOutputOpenDrain);
 | 
					    gpio_init(led_record, GpioModeOutputOpenDrain);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // get_default_log open "tty" record
 | 
					    // get_default_log open "tty" record
 | 
				
			||||||
    FuriRecordSubscriber* log = get_default_log();
 | 
					    FuriRecordSubscriber* log = get_default_log();
 | 
				
			||||||
@ -27,9 +27,9 @@ void application_uart_write(void* p) {
 | 
				
			|||||||
        counter++;
 | 
					        counter++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // flash at every send
 | 
					        // flash at every send
 | 
				
			||||||
        digitalWrite(led_record, LOW);
 | 
					        gpio_write(led_record, false);
 | 
				
			||||||
        delay(50);
 | 
					        delay(50);
 | 
				
			||||||
        digitalWrite(led_record, HIGH);
 | 
					        gpio_write(led_record, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // delay with overall perion of 1s
 | 
					        // delay with overall perion of 1s
 | 
				
			||||||
        delay(950);
 | 
					        delay(950);
 | 
				
			||||||
 | 
				
			|||||||
@ -80,12 +80,10 @@ void render_carrier(CanvasApi* canvas, State* state) {
 | 
				
			|||||||
    canvas->draw_str(canvas, 2, 37, "? /\\ freq | \\/ duty cycle");
 | 
					    canvas->draw_str(canvas, 2, 37, "? /\\ freq | \\/ duty cycle");
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        char buf[24];
 | 
					        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);
 | 
					        canvas->draw_str(canvas, 2, 50, buf);
 | 
				
			||||||
        sprintf(
 | 
					        sprintf(
 | 
				
			||||||
            buf,
 | 
					            buf, "duty cycle: %d/1000", (int)(duty_cycles[state->carrier_duty_cycle_id] * 1000));
 | 
				
			||||||
            "duty cycle: %d/1000",
 | 
					 | 
				
			||||||
            (uint32_t)(duty_cycles[state->carrier_duty_cycle_id] * 1000));
 | 
					 | 
				
			||||||
        canvas->draw_str(canvas, 2, 62, buf);
 | 
					        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");
 | 
					    canvas->draw_str(canvas, 2, 24, state->on ? "ON" : "OFF");
 | 
				
			||||||
    char buf[12];
 | 
					    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);
 | 
					    canvas->draw_str(canvas, 2, 36, buf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    release_mutex((ValueMutex*)ctx, state);
 | 
					    release_mutex((ValueMutex*)ctx, state);
 | 
				
			||||||
 | 
				
			|||||||
@ -15,6 +15,8 @@
 | 
				
			|||||||
#include <rfal_nfc.h>
 | 
					#include <rfal_nfc.h>
 | 
				
			||||||
#include <rfal_nfca.h>
 | 
					#include <rfal_nfca.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <st25r3916_irq.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "dispatcher.h"
 | 
					#include "dispatcher.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef enum {
 | 
					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) {
 | 
					void power_input_events_callback(const void* value, void* ctx) {
 | 
				
			||||||
    assert(ctx);
 | 
					    assert(ctx);
 | 
				
			||||||
    Power* power = ctx;
 | 
					    Power* power = ctx;
 | 
				
			||||||
    InputEvent* event = value;
 | 
					    const InputEvent* event = value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(event->input != InputCharging) return;
 | 
					    if(event->input != InputCharging) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -63,7 +63,7 @@ Power* power_alloc() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    ValueManager* input_state_manager = furi_open("input_state");
 | 
					    ValueManager* input_state_manager = furi_open("input_state");
 | 
				
			||||||
    InputState 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_enabled_set(power->usb_widget, input_state.charging);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    widget_draw_callback_set(power->usb_widget, power_draw_usb_callback, power);
 | 
					    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));
 | 
					    mu_check(!wait_event_with_timeout(&event, 100));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Create second app
 | 
					    // 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
 | 
					    // The event should be signalled now
 | 
				
			||||||
    mu_check(wait_event_with_timeout(&event, 100));
 | 
					    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_value = 0;
 | 
				
			||||||
uint32_t pubsub_context_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_value = *(uint32_t*)arg;
 | 
				
			||||||
    pubsub_context_value = *(uint32_t*)ctx;
 | 
					    pubsub_context_value = *(uint32_t*)ctx;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -112,7 +112,7 @@ static const uint32_t notify_value_1 = 0x11223344;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static uint32_t pubsub_value = 0;
 | 
					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;
 | 
					    pubsub_value = *(uint32_t*)arg;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -76,8 +76,8 @@ extern "C" {
 | 
				
			|||||||
#include "minunit_vars_ex.h"
 | 
					#include "minunit_vars_ex.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*  Test setup and teardown function pointers */
 | 
					/*  Test setup and teardown function pointers */
 | 
				
			||||||
static void (*minunit_setup)(void) = NULL;
 | 
					__attribute__((unused)) static void (*minunit_setup)(void) = NULL;
 | 
				
			||||||
static void (*minunit_teardown)(void) = NULL;
 | 
					__attribute__((unused)) static void (*minunit_teardown)(void) = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*  Definitions */
 | 
					/*  Definitions */
 | 
				
			||||||
#define MU_TEST(method_name) static void method_name(void)
 | 
					#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
 | 
					 * The returned real time is only useful for computing an elapsed time
 | 
				
			||||||
 * between two calls to this function.
 | 
					 * between two calls to this function.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static double mu_timer_real(void) {
 | 
					__attribute__((unused)) static double mu_timer_real(void) {
 | 
				
			||||||
#if defined(_WIN32)
 | 
					#if defined(_WIN32)
 | 
				
			||||||
    /* Windows 2000 and later. ---------------------------------- */
 | 
					    /* Windows 2000 and later. ---------------------------------- */
 | 
				
			||||||
    LARGE_INTEGER Time;
 | 
					    LARGE_INTEGER Time;
 | 
				
			||||||
@ -529,7 +529,7 @@ static double mu_timer_real(void) {
 | 
				
			|||||||
 * Returns the amount of CPU time used by the current process,
 | 
					 * Returns the amount of CPU time used by the current process,
 | 
				
			||||||
 * in seconds, or -1.0 if an error occurred.
 | 
					 * 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)
 | 
					#if defined(_WIN32)
 | 
				
			||||||
    /* Windows -------------------------------------------------- */
 | 
					    /* Windows -------------------------------------------------- */
 | 
				
			||||||
    FILETIME createTime;
 | 
					    FILETIME createTime;
 | 
				
			||||||
 | 
				
			|||||||
@ -18,26 +18,26 @@ void flipper_test_app(void* p) {
 | 
				
			|||||||
    GpioPin* blue_record = &blue;
 | 
					    GpioPin* blue_record = &blue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // configure pins
 | 
					    // configure pins
 | 
				
			||||||
    pinMode(red_record, GpioModeOutputOpenDrain);
 | 
					    gpio_init(red_record, GpioModeOutputOpenDrain);
 | 
				
			||||||
    pinMode(green_record, GpioModeOutputOpenDrain);
 | 
					    gpio_init(green_record, GpioModeOutputOpenDrain);
 | 
				
			||||||
    pinMode(blue_record, GpioModeOutputOpenDrain);
 | 
					    gpio_init(blue_record, GpioModeOutputOpenDrain);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    digitalWrite(red_record, HIGH);
 | 
					    gpio_write(red_record, true);
 | 
				
			||||||
    digitalWrite(green_record, HIGH);
 | 
					    gpio_write(green_record, true);
 | 
				
			||||||
    digitalWrite(blue_record, LOW);
 | 
					    gpio_write(blue_record, false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    uint32_t exitcode = run_minunit();
 | 
					    uint32_t exitcode = run_minunit();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if(exitcode == 0) {
 | 
					    if(exitcode == 0) {
 | 
				
			||||||
        // test passed
 | 
					        // test passed
 | 
				
			||||||
        digitalWrite(red_record, HIGH);
 | 
					        gpio_write(red_record, true);
 | 
				
			||||||
        digitalWrite(green_record, LOW);
 | 
					        gpio_write(green_record, false);
 | 
				
			||||||
        digitalWrite(blue_record, HIGH);
 | 
					        gpio_write(blue_record, true);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        // test failed
 | 
					        // test failed
 | 
				
			||||||
        digitalWrite(red_record, LOW);
 | 
					        gpio_write(red_record, false);
 | 
				
			||||||
        digitalWrite(green_record, HIGH);
 | 
					        gpio_write(green_record, true);
 | 
				
			||||||
        digitalWrite(blue_record, HIGH);
 | 
					        gpio_write(blue_record, true);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    set_exitcode(exitcode);
 | 
					    set_exitcode(exitcode);
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,7 @@ and also subscriber can set `void*` context pointer that pass into
 | 
				
			|||||||
callback (you can see callback signature below).
 | 
					callback (you can see callback signature below).
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef void (*PubSubCallback)(void*, void*);
 | 
					typedef void (*PubSubCallback)(const void*, void*);
 | 
				
			||||||
typedef struct PubSubType PubSub;
 | 
					typedef struct PubSubType PubSub;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct {
 | 
					typedef struct {
 | 
				
			||||||
 | 
				
			|||||||
@ -23,7 +23,7 @@ static inline void gpio_write(GpioPin* gpio, bool state) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// read value from GPIO, false = LOW, true = HIGH
 | 
					// 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);
 | 
					    return hal_gpio_read(gpio);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -17,7 +17,6 @@ extern "C" {
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include "flipper_arduino.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
void set_exitcode(uint32_t _exitcode);
 | 
					void set_exitcode(uint32_t _exitcode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
#include "flipper.h"
 | 
					#include "flipper.h"
 | 
				
			||||||
 | 
					#include "api-hal-task.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: this file contains printf, that not implemented on uC target
 | 
					// TODO: this file contains printf, that not implemented on uC target
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,9 @@
 | 
				
			|||||||
PROJECT_ROOT	= $(abspath $(dir $(abspath $(firstword $(MAKEFILE_LIST))))..)
 | 
					PROJECT_ROOT	= $(abspath $(dir $(abspath $(firstword $(MAKEFILE_LIST))))..)
 | 
				
			||||||
PROJECT			= firmware
 | 
					PROJECT			= firmware
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CFLAGS += -Werror
 | 
				
			||||||
 | 
					CPPFLAGS += -Werror
 | 
				
			||||||
 | 
					
 | 
				
			||||||
include 		$(PROJECT_ROOT)/make/base.mk
 | 
					include 		$(PROJECT_ROOT)/make/base.mk
 | 
				
			||||||
include			$(PROJECT_ROOT)/assets/assets.mk
 | 
					include			$(PROJECT_ROOT)/assets/assets.mk
 | 
				
			||||||
include			$(PROJECT_ROOT)/core/core.mk
 | 
					include			$(PROJECT_ROOT)/core/core.mk
 | 
				
			||||||
 | 
				
			|||||||
@ -36,7 +36,8 @@
 | 
				
			|||||||
#include "stm32l4xx_hal.h"
 | 
					#include "stm32l4xx_hal.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* USER CODE BEGIN INCLUDE */
 | 
					/* USER CODE BEGIN INCLUDE */
 | 
				
			||||||
 | 
					void *USBD_static_malloc(uint32_t size);
 | 
				
			||||||
 | 
					void USBD_static_free(void* p);
 | 
				
			||||||
/* USER CODE END INCLUDE */
 | 
					/* USER CODE END INCLUDE */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/** @addtogroup USBD_OTG_DRIVER
 | 
					/** @addtogroup USBD_OTG_DRIVER
 | 
				
			||||||
 | 
				
			|||||||
@ -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 ***
 | 
					 | 
				
			||||||
@ -51,7 +51,7 @@ static void SPIx_WriteReadData(const uint8_t* DataIn, uint8_t* DataOut, uint16_t
 | 
				
			|||||||
 * @param  Value: value to be written
 | 
					 * @param  Value: value to be written
 | 
				
			||||||
 * @retval None
 | 
					 * @retval None
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
static void SPIx_Write(uint8_t Value) {
 | 
					__attribute__((unused)) static void SPIx_Write(uint8_t Value) {
 | 
				
			||||||
    HAL_StatusTypeDef status = HAL_OK;
 | 
					    HAL_StatusTypeDef status = HAL_OK;
 | 
				
			||||||
    uint8_t data;
 | 
					    uint8_t data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +0,0 @@
 | 
				
			|||||||
#include <cmsis_os.h>
 | 
					 | 
				
			||||||
#include <stdbool.h>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
bool task_equal(TaskHandle_t a, TaskHandle_t b) {
 | 
					 | 
				
			||||||
    if(a == NULL || b == NULL) return false;
 | 
					 | 
				
			||||||
    return a == b;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,4 +1,6 @@
 | 
				
			|||||||
#include "api-hal-delay.h"
 | 
					#include "api-hal-delay.h"
 | 
				
			||||||
 | 
					#include "assert.h"
 | 
				
			||||||
 | 
					#include "cmsis_os2.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void delay_us_init_DWT(void) {
 | 
					void delay_us_init_DWT(void) {
 | 
				
			||||||
    CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
 | 
					    CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
 | 
				
			||||||
@ -6,9 +8,17 @@ void delay_us_init_DWT(void) {
 | 
				
			|||||||
    DWT->CYCCNT = 0U;
 | 
					    DWT->CYCCNT = 0U;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void delay_us(float time) {
 | 
					void delay_us(float microseconds) {
 | 
				
			||||||
    uint32_t start = DWT->CYCCNT;
 | 
					    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) {
 | 
					    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);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,5 +1,6 @@
 | 
				
			|||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
#include "main.h"
 | 
					#include "main.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void delay_us(float time);
 | 
					void delay(float milliseconds);
 | 
				
			||||||
 | 
					void delay_us(float microseconds);
 | 
				
			||||||
void delay_us_init_DWT(void);
 | 
					void delay_us_init_DWT(void);
 | 
				
			||||||
@ -52,7 +52,7 @@ static inline void hal_gpio_write(GpioPin* gpio, bool state) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// read value from GPIO, false = LOW, true = HIGH
 | 
					// 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) {
 | 
					    if((gpio->port->IDR & gpio->pin) != 0x00U) {
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
#include "api-hal-task.h"
 | 
					 | 
				
			||||||
#include "cmsis_os.h"
 | 
					#include "cmsis_os.h"
 | 
				
			||||||
 | 
					#include "api-hal-task.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//-----------------------------cmsis_os2.c-------------------------------
 | 
					//-----------------------------cmsis_os2.c-------------------------------
 | 
				
			||||||
// helpers to get isr context
 | 
					// helpers to get isr context
 | 
				
			||||||
@ -52,3 +52,8 @@
 | 
				
			|||||||
bool task_is_isr_context(void) {
 | 
					bool task_is_isr_context(void) {
 | 
				
			||||||
    return IS_IRQ();
 | 
					    return IS_IRQ();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool task_equal(TaskHandle_t a, TaskHandle_t b) {
 | 
				
			||||||
 | 
					    if(a == NULL || b == NULL) return false;
 | 
				
			||||||
 | 
					    return a == b;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,5 +1,7 @@
 | 
				
			|||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
#include "main.h"
 | 
					#include "main.h"
 | 
				
			||||||
 | 
					#include <cmsis_os.h>
 | 
				
			||||||
#include <stdbool.h>
 | 
					#include <stdbool.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool task_equal(TaskHandle_t a, TaskHandle_t b);
 | 
				
			||||||
bool task_is_isr_context(void);
 | 
					bool task_is_isr_context(void);
 | 
				
			||||||
@ -47,7 +47,6 @@ TaskHandle_t xTaskCreateStatic(TaskFunction_t pxTaskCode,
 | 
				
			|||||||
void vTaskDelete(TaskHandle_t xTask);
 | 
					void vTaskDelete(TaskHandle_t xTask);
 | 
				
			||||||
TaskHandle_t xTaskGetCurrentTaskHandle(void);
 | 
					TaskHandle_t xTaskGetCurrentTaskHandle(void);
 | 
				
			||||||
SemaphoreHandle_t xSemaphoreCreateMutexStatic(StaticSemaphore_t* pxMutexBuffer);
 | 
					SemaphoreHandle_t xSemaphoreCreateMutexStatic(StaticSemaphore_t* pxMutexBuffer);
 | 
				
			||||||
bool task_equal(TaskHandle_t a, TaskHandle_t b);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
QueueHandle_t xQueueCreateStatic(UBaseType_t uxQueueLength,
 | 
					QueueHandle_t xQueueCreateStatic(UBaseType_t uxQueueLength,
 | 
				
			||||||
                                 UBaseType_t uxItemSize,
 | 
					                                 UBaseType_t uxItemSize,
 | 
				
			||||||
 | 
				
			|||||||
@ -16,4 +16,6 @@ HAL_UART_Transmit(UART_HandleTypeDef* handle, uint8_t* bufer, uint16_t size, uin
 | 
				
			|||||||
    return res;
 | 
					    return res;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void BSP_SD_Init() {}
 | 
					uint8_t BSP_SD_Init() {
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -74,12 +74,6 @@ TaskHandle_t xTaskGetCurrentTaskHandle(void) {
 | 
				
			|||||||
    return thread;
 | 
					    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) {
 | 
					BaseType_t xQueueSend(QueueHandle_t xQueue, const void* pvItemToQueue, TickType_t xTicksToWait) {
 | 
				
			||||||
    // TODO: add implementation
 | 
					    // TODO: add implementation
 | 
				
			||||||
    return pdTRUE;
 | 
					    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) {
 | 
					osSemaphoreId_t osSemaphoreNew(uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr) {
 | 
				
			||||||
    if(max_count != 1) {
 | 
					    if(max_count != 1) {
 | 
				
			||||||
        // Non-binary semaphors are not supported at the moment
 | 
					        // Non-binary semaphors are not supported at the moment
 | 
				
			||||||
        return osErrorParameter;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if(attr != NULL) {
 | 
					    if(attr != NULL) {
 | 
				
			||||||
        // Attributes are not supported at the moment
 | 
					        // Attributes are not supported at the moment
 | 
				
			||||||
        return osErrorParameter;
 | 
					        return NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SemaphoreHandle_t handle = osMutexNew(NULL);
 | 
					    SemaphoreHandle_t handle = osMutexNew(NULL);
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,11 @@
 | 
				
			|||||||
#include "api-hal-delay.h"
 | 
					#include "api-hal-delay.h"
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void delay_us(uint32_t time) {
 | 
					void delay_us(float microseconds) {
 | 
				
			||||||
    // How to deal with it
 | 
					    usleep(microseconds);
 | 
				
			||||||
    printf("[DELAY] %d us\n", time);
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void delay(float milliseconds) {
 | 
				
			||||||
 | 
					    usleep(milliseconds * 1000);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -1,4 +1,6 @@
 | 
				
			|||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
#include "main.h"
 | 
					#include "main.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void delay_us(uint32_t time);
 | 
					void delay_us(float microseconds);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void delay(float milliseconds);
 | 
				
			||||||
@ -41,7 +41,7 @@ void hal_gpio_write(GpioPin* gpio, bool state){
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// read value from GPIO, false = LOW, true = HIGH
 | 
					// 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?
 | 
					    // TODO emulate pin state?
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -46,4 +46,4 @@ void hal_gpio_init(GpioPin* gpio, GpioMode mode, GpioPull pull, GpioSpeed speed)
 | 
				
			|||||||
void hal_gpio_write(GpioPin* gpio, bool state);
 | 
					void hal_gpio_write(GpioPin* gpio, bool state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// read value from GPIO, false = LOW, true = HIGH
 | 
					// read value from GPIO, false = LOW, true = HIGH
 | 
				
			||||||
bool hal_gpio_read(GpioPin* gpio);
 | 
					bool hal_gpio_read(const GpioPin* gpio);
 | 
				
			||||||
@ -1,5 +1,14 @@
 | 
				
			|||||||
#include "api-hal-task.h"
 | 
					#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) {
 | 
					bool task_is_isr_context(void) {
 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void taskDISABLE_INTERRUPTS(void){
 | 
				
			||||||
 | 
					    // we cant disable main os sheduler
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,8 @@
 | 
				
			|||||||
#pragma once
 | 
					#pragma once
 | 
				
			||||||
#include "main.h"
 | 
					#include "main.h"
 | 
				
			||||||
 | 
					#include <cmsis_os.h>
 | 
				
			||||||
#include <stdbool.h>
 | 
					#include <stdbool.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool task_equal(TaskHandle_t a, TaskHandle_t b);
 | 
				
			||||||
bool task_is_isr_context(void);
 | 
					bool task_is_isr_context(void);
 | 
				
			||||||
 | 
					__attribute__((unused)) void taskDISABLE_INTERRUPTS(void);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user