Refactor F2/local before F3 merge (#220)
* add files from f3 * rollback lfs * Move assets from LFS * remove lfs from build Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -46,6 +46,10 @@ const FlipperStartupApp FLIPPER_STARTUP[] = {
|
||||
{.app = input_task, .name = "input_task", .libs = {0}},
|
||||
#endif
|
||||
|
||||
#ifdef APP_EXAMPLE_INPUT_DUMP
|
||||
{.app = application_input_dump, .name = "input dump", .libs = {1, FURI_LIB{"input_task"}}},
|
||||
#endif
|
||||
|
||||
#ifdef APP_GUI
|
||||
{.app = backlight_control, .name = "backlight_control", .libs = {1, FURI_LIB{"input_task"}}},
|
||||
{.app = gui_task, .name = "gui_task", .libs = {0}},
|
||||
@@ -102,7 +106,7 @@ const FlipperStartupApp FLIPPER_STARTUP[] = {
|
||||
#endif
|
||||
|
||||
#ifdef APP_SPEAKER_DEMO
|
||||
{.app = coreglitch_demo_0, .name = "coreglitch_demo_0", .libs = ""},
|
||||
{.app = coreglitch_demo_0, .name = "coreglitch_demo_0", .libs = {0}},
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@@ -7,8 +7,15 @@ static void event_cb(const void* value, void* ctx) {
|
||||
const uint32_t BACKLIGHT_TIME = 10000;
|
||||
|
||||
void backlight_control(void* p) {
|
||||
// TODO use FURI
|
||||
HAL_GPIO_WritePin(DISPLAY_BACKLIGHT_GPIO_Port, DISPLAY_BACKLIGHT_Pin, GPIO_PIN_SET);
|
||||
// create pin
|
||||
GpioPin backlight = backlight_gpio;
|
||||
|
||||
// TODO open record
|
||||
GpioPin* backlight_record = &backlight;
|
||||
|
||||
// configure pin
|
||||
gpio_init(backlight_record, GpioModeOutputPushPull);
|
||||
gpio_write(backlight_record, true);
|
||||
|
||||
StaticSemaphore_t event_descriptor;
|
||||
SemaphoreHandle_t update = xSemaphoreCreateCountingStatic(255, 0, &event_descriptor);
|
||||
@@ -24,9 +31,9 @@ void backlight_control(void* p) {
|
||||
while(1) {
|
||||
// wait for event
|
||||
if(xSemaphoreTake(update, BACKLIGHT_TIME) == pdTRUE) {
|
||||
HAL_GPIO_WritePin(DISPLAY_BACKLIGHT_GPIO_Port, DISPLAY_BACKLIGHT_Pin, GPIO_PIN_SET);
|
||||
gpio_write(backlight_record, true);
|
||||
} else {
|
||||
HAL_GPIO_WritePin(DISPLAY_BACKLIGHT_GPIO_Port, DISPLAY_BACKLIGHT_Pin, GPIO_PIN_RESET);
|
||||
gpio_write(backlight_record, false);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
#include "flipper_v2.h"
|
||||
#include "cc1101-workaround/cc1101.h"
|
||||
#include "spi.h"
|
||||
|
||||
// ******************************************************************************
|
||||
#define WRITE_BURST 0x40
|
||||
@@ -27,34 +28,14 @@ CC1101::CC1101(GpioPin* ss_pin) {
|
||||
//******************************************************************************
|
||||
//SpiInit
|
||||
/******************************************************************************/
|
||||
extern SPI_HandleTypeDef hspi3;
|
||||
extern SPI_HandleTypeDef SPI_R;
|
||||
void CC1101::SpiInit(void) {
|
||||
//initialize spi pins
|
||||
|
||||
//Enable spi master, MSB, SPI mode 0, FOSC/4
|
||||
SpiMode(0);
|
||||
|
||||
if(HAL_SPI_DeInit(&hspi3) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
hspi3.Init.Mode = SPI_MODE_MASTER;
|
||||
hspi3.Init.Direction = SPI_DIRECTION_2LINES;
|
||||
hspi3.Init.DataSize = SPI_DATASIZE_8BIT;
|
||||
hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;
|
||||
hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;
|
||||
hspi3.Init.NSS = SPI_NSS_SOFT;
|
||||
hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
|
||||
hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
||||
hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||
hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||
hspi3.Init.CRCPolynomial = 7;
|
||||
hspi3.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
|
||||
hspi3.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;
|
||||
|
||||
if(HAL_SPI_Init(&hspi3) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
CC1101_SPI_Reconfigure();
|
||||
}
|
||||
|
||||
void CC1101::SpiEnd(void) {
|
||||
@@ -99,7 +80,7 @@ uint8_t CC1101::SpiTransfer(uint8_t value) {
|
||||
uint8_t buf[1] = {value};
|
||||
uint8_t rxbuf[1] = {0};
|
||||
|
||||
HAL_SPI_TransmitReceive(&hspi3, buf, rxbuf, 1, HAL_MAX_DELAY);
|
||||
HAL_SPI_TransmitReceive(&SPI_R, buf, rxbuf, 1, HAL_MAX_DELAY);
|
||||
|
||||
return rxbuf[0];
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include "flipper.h"
|
||||
#include "u8g2/u8g2.h"
|
||||
|
||||
extern TIM_HandleTypeDef htim5;
|
||||
extern TIM_HandleTypeDef SPEAKER_TIM;
|
||||
|
||||
void coreglitch_demo_0(void* p) {
|
||||
FuriRecordSubscriber* log = get_default_log();
|
||||
@@ -40,7 +40,8 @@ void coreglitch_demo_0(void* p) {
|
||||
}
|
||||
|
||||
// TODO get sound from FURI
|
||||
hal_pwm_set(width, freq, &htim5, TIM_CHANNEL_4);
|
||||
hal_pwm_set(width, freq, &SPEAKER_TIM, SPEAKER_CH);
|
||||
|
||||
// delay(1);
|
||||
|
||||
cnt++;
|
||||
|
@@ -1,7 +1,8 @@
|
||||
#include "u8g2/u8g2.h"
|
||||
#include "flipper.h"
|
||||
#include "main.h"
|
||||
|
||||
extern SPI_HandleTypeDef hspi1;
|
||||
extern SPI_HandleTypeDef SPI_D;
|
||||
|
||||
// TODO: fix log
|
||||
#ifdef DEBUG
|
||||
@@ -63,7 +64,7 @@ static uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, voi
|
||||
#endif
|
||||
|
||||
// TODO change it to FuriRecord SPI
|
||||
HAL_SPI_Transmit(&hspi1, (uint8_t*)arg_ptr, arg_int, 10000);
|
||||
HAL_SPI_Transmit(&SPI_D, (uint8_t*)arg_ptr, arg_int, 10000);
|
||||
break;
|
||||
|
||||
case U8X8_MSG_BYTE_SET_DC:
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
void application_blink(void* p) {
|
||||
// create pin
|
||||
GpioPin led = {.pin = GPIO_PIN_8, .port = GPIOA};
|
||||
GpioPin led = led_gpio[0];
|
||||
|
||||
// TODO open record
|
||||
GpioPin* led_record = &led;
|
||||
|
@@ -50,55 +50,37 @@ void fatfs_list(void* p) {
|
||||
QueueHandle_t event_queue = xQueueCreate(2, sizeof(AppEvent));
|
||||
|
||||
furi_log = get_default_log();
|
||||
fuprintf(furi_log, "[fatfs_list] app start\n");
|
||||
|
||||
FuriRecordSubscriber* fb_record =
|
||||
furi_open_deprecated("u8g2_fb", false, false, NULL, NULL, NULL);
|
||||
if(fb_record == NULL) {
|
||||
fuprintf(furi_log, "[widget][fatfs_list] cannot create fb record\n");
|
||||
fuprintf(furi_log, "[fatfs_list] cannot create fb record\n");
|
||||
furiac_exit(NULL);
|
||||
}
|
||||
|
||||
PubSub* event_record = furi_open("input_events");
|
||||
if(event_record == NULL) {
|
||||
fuprintf(furi_log, "[widget][fatfs_list] cannot open input_events record\n");
|
||||
fuprintf(furi_log, "[fatfs_list] cannot open input_events record\n");
|
||||
furiac_exit(NULL);
|
||||
}
|
||||
PubSubItem* subscription = subscribe_pubsub(event_record, event_cb, event_queue);
|
||||
if(subscription == NULL) {
|
||||
fuprintf(furi_log, "[widget][fatfs_list] cannot register input_events callback\n");
|
||||
fuprintf(furi_log, "[fatfs_list] cannot register input_events callback\n");
|
||||
furiac_exit(NULL);
|
||||
}
|
||||
|
||||
// clear display
|
||||
u8g2_t* fb = furi_take(fb_record);
|
||||
u8g2_ClearBuffer(fb);
|
||||
furi_commit(fb_record);
|
||||
|
||||
bsp_result = BSP_SD_Init();
|
||||
|
||||
if(bsp_result != 0) {
|
||||
furi_take(fb_record);
|
||||
|
||||
u8g2_SetFont(fb, u8g2_font_6x10_mf);
|
||||
u8g2_SetDrawColor(fb, 1);
|
||||
u8g2_SetFontMode(fb, 1);
|
||||
u8g2_DrawStr(fb, 0, 12, "SD card init error");
|
||||
|
||||
furi_commit(fb_record);
|
||||
fuprintf(furi_log, "[fatfs_list] SD card init error\n");
|
||||
furiac_exit(NULL);
|
||||
}
|
||||
|
||||
result = f_mount(&SD_FatFs, (TCHAR const*)SD_Path, 1);
|
||||
|
||||
if(result != FR_OK) {
|
||||
furi_take(fb_record);
|
||||
|
||||
u8g2_SetFont(fb, u8g2_font_6x10_mf);
|
||||
u8g2_SetDrawColor(fb, 1);
|
||||
u8g2_SetFontMode(fb, 1);
|
||||
u8g2_DrawStr(fb, 0, 12, "SD card mount error");
|
||||
|
||||
furi_commit(fb_record);
|
||||
fuprintf(furi_log, "[fatfs_list] SD card mount error\n");
|
||||
furiac_exit(NULL);
|
||||
}
|
||||
|
||||
@@ -123,12 +105,6 @@ void fatfs_list(void* p) {
|
||||
}
|
||||
}
|
||||
|
||||
// get display and draw
|
||||
furi_take(fb_record);
|
||||
u8g2_ClearBuffer(fb);
|
||||
u8g2_SetFont(fb, u8g2_font_6x10_mf);
|
||||
u8g2_SetDrawColor(fb, 1);
|
||||
u8g2_SetFontMode(fb, 1);
|
||||
line_current = 1;
|
||||
|
||||
// open root dir
|
||||
@@ -156,8 +132,7 @@ void fatfs_list(void* p) {
|
||||
} else {
|
||||
snprintf(str_buffer, STR_BUFFER_SIZE, "FIL %s\n", fno.fname);
|
||||
}
|
||||
|
||||
u8g2_DrawStr(fb, 0, line_size * (line_current - line_position), str_buffer);
|
||||
fuprintf(furi_log, str_buffer);
|
||||
}
|
||||
|
||||
line_current++;
|
||||
|
@@ -29,6 +29,8 @@ void application_input_dump(void* p) {
|
||||
furi_check(event_record);
|
||||
subscribe_pubsub(event_record, event_cb, NULL);
|
||||
|
||||
printf("Example app [input dump]\n");
|
||||
|
||||
for(;;) {
|
||||
delay(100);
|
||||
}
|
||||
|
@@ -1,7 +1,8 @@
|
||||
#include "u8g2/u8g2.h"
|
||||
#include "flipper.h"
|
||||
#include <main.h>
|
||||
|
||||
extern SPI_HandleTypeDef hspi1;
|
||||
extern SPI_HandleTypeDef SPI_D;
|
||||
|
||||
// TODO: fix log
|
||||
#ifdef DEBUG
|
||||
@@ -60,7 +61,7 @@ uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_
|
||||
#endif
|
||||
|
||||
// TODO change it to FuriRecord SPI
|
||||
HAL_SPI_Transmit(&hspi1, (uint8_t*)arg_ptr, arg_int, 10000);
|
||||
HAL_SPI_Transmit(&SPI_D, (uint8_t*)arg_ptr, arg_int, 10000);
|
||||
break;
|
||||
|
||||
case U8X8_MSG_BYTE_SET_DC:
|
||||
|
@@ -1,5 +1,4 @@
|
||||
#include <input/input.h>
|
||||
#include <input_priv.h>
|
||||
#include <stdio.h>
|
||||
#include <flipper_v2.h>
|
||||
|
||||
@@ -54,7 +53,14 @@ void input_task(void* p) {
|
||||
for(;;) {
|
||||
bool changed = false;
|
||||
for(uint32_t i = 0; i < INPUT_COUNT; i++) {
|
||||
bool input_state = gpio_read(&input_gpio[i]) ^ input_invert[i];
|
||||
bool input_state = false;
|
||||
|
||||
// dirty hack, f3 has no CHARGING pin
|
||||
// TODO rewrite this
|
||||
if(i < GPIO_INPUT_PINS_COUNT) {
|
||||
input_state = gpio_read(&input_gpio[i]) ^ input_invert[i];
|
||||
}
|
||||
|
||||
if(input_state) {
|
||||
if(debounce_counters[i] < DEBOUNCE_TICKS) {
|
||||
debounce_counters[i] += 1;
|
||||
@@ -103,7 +109,7 @@ void input_task(void* p) {
|
||||
|
||||
void HAL_GPIO_EXTI_Callback(uint16_t pin) {
|
||||
#ifdef APP_NFC
|
||||
if(pin == RFID_PULL_Pin) {
|
||||
if(pin == NFC_IRQ_Pin) {
|
||||
nfc_isr();
|
||||
return;
|
||||
}
|
||||
|
@@ -7,6 +7,7 @@
|
||||
typedef enum {
|
||||
EventTypeTick,
|
||||
EventTypeKey,
|
||||
EventTypeLed,
|
||||
} EventType;
|
||||
|
||||
typedef struct {
|
||||
@@ -121,13 +122,9 @@ void render_samsung(CanvasApi* canvas, State* state) {
|
||||
void input_carrier(AppEvent* event, State* state) {
|
||||
if(event->value.input.input == InputOk) {
|
||||
if(event->value.input.state) {
|
||||
hal_pwm_set(
|
||||
duty_cycles[state->carrier_duty_cycle_id],
|
||||
state->carrier_freq,
|
||||
&htim2,
|
||||
TIM_CHANNEL_4);
|
||||
irda_pwm_set(duty_cycles[state->carrier_duty_cycle_id], state->carrier_freq);
|
||||
} else {
|
||||
hal_pwm_stop(&htim2, TIM_CHANNEL_4);
|
||||
irda_pwm_stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4,18 +4,18 @@
|
||||
|
||||
void ir_nec_preambula(void) {
|
||||
// 9ms carrier + 4.5ms pause
|
||||
hal_pwm_set(NEC_DUTY_CYCLE, NEC_CARRIER_FREQUENCY, &htim2, TIM_CHANNEL_4);
|
||||
irda_pwm_set(NEC_DUTY_CYCLE, NEC_CARRIER_FREQUENCY);
|
||||
delay_us(9000);
|
||||
hal_pwm_stop(&htim2, TIM_CHANNEL_4);
|
||||
irda_pwm_stop();
|
||||
delay_us(4500);
|
||||
}
|
||||
|
||||
void ir_nec_send_bit(bool bit) {
|
||||
// 0 is 562.5us carrier + 1687.5us pause
|
||||
// 1 is 562.5us carrier + 562.5us pause
|
||||
hal_pwm_set(NEC_DUTY_CYCLE, NEC_CARRIER_FREQUENCY, &htim2, TIM_CHANNEL_4);
|
||||
irda_pwm_set(NEC_DUTY_CYCLE, NEC_CARRIER_FREQUENCY);
|
||||
delay_us(562.5);
|
||||
hal_pwm_stop(&htim2, TIM_CHANNEL_4);
|
||||
irda_pwm_stop();
|
||||
if(bit) {
|
||||
delay_us(562.5);
|
||||
} else {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// our tx pin is TIM2_CH4
|
||||
extern TIM_HandleTypeDef htim2;
|
||||
extern TIM_HandleTypeDef TIM_A;
|
||||
|
||||
#define RC5_CARRIER_FREQUENCY 36000
|
||||
#define RC5_DUTY_CYCLE 0.33
|
||||
|
@@ -3,16 +3,16 @@
|
||||
#include "irda_protocols.h"
|
||||
|
||||
void ir_samsung_preambula(void) {
|
||||
hal_pwm_set(SAMSUNG_DUTY_CYCLE, SAMSUNG_CARRIER_FREQUENCY, &htim2, TIM_CHANNEL_4);
|
||||
irda_pwm_set(SAMSUNG_DUTY_CYCLE, SAMSUNG_CARRIER_FREQUENCY);
|
||||
delay_us(4500);
|
||||
hal_pwm_stop(&htim2, TIM_CHANNEL_4);
|
||||
irda_pwm_stop();
|
||||
delay_us(4500);
|
||||
}
|
||||
|
||||
void ir_samsung_send_bit(bool bit) {
|
||||
hal_pwm_set(SAMSUNG_DUTY_CYCLE, SAMSUNG_CARRIER_FREQUENCY, &htim2, TIM_CHANNEL_4);
|
||||
irda_pwm_set(SAMSUNG_DUTY_CYCLE, SAMSUNG_CARRIER_FREQUENCY);
|
||||
delay_us(560);
|
||||
hal_pwm_stop(&htim2, TIM_CHANNEL_4);
|
||||
irda_pwm_stop();
|
||||
if(bit) {
|
||||
delay_us(1590);
|
||||
} else {
|
||||
|
@@ -43,7 +43,7 @@ static void input_callback(InputEvent* input_event, void* ctx) {
|
||||
osMessageQueuePut(event_queue, &event, 0, 0);
|
||||
}
|
||||
|
||||
extern TIM_HandleTypeDef htim15;
|
||||
extern TIM_HandleTypeDef TIM_C;
|
||||
void em4100_emulation(uint8_t* data, GpioPin* pin);
|
||||
void prepare_data(uint32_t ID, uint32_t VENDOR, uint8_t* data);
|
||||
|
||||
@@ -51,7 +51,7 @@ void lf_rfid_workaround(void* p) {
|
||||
osMessageQueueId_t event_queue = osMessageQueueNew(1, sizeof(AppEvent), NULL);
|
||||
|
||||
// create pin
|
||||
GpioPin pull_pin = {.pin = GPIO_PIN_15, .port = GPIOB};
|
||||
GpioPin pull_pin = {.pin = RFID_PULL_Pin, .port = RFID_PULL_GPIO_Port};
|
||||
// TODO open record
|
||||
GpioPin* pull_pin_record = &pull_pin;
|
||||
|
||||
@@ -92,7 +92,7 @@ void lf_rfid_workaround(void* p) {
|
||||
if(event.type == EventTypeKey) {
|
||||
// press events
|
||||
if(event.value.input.state && event.value.input.input == InputBack) {
|
||||
hal_pwmn_stop(&htim15, TIM_CHANNEL_1); // TODO: move to furiac_onexit
|
||||
hal_pwmn_stop(&TIM_C, TIM_CHANNEL_1); // TODO: move to furiac_onexit
|
||||
gpio_init(pull_pin_record, GpioModeInput);
|
||||
// TODO remove all widgets create by app
|
||||
widget_enabled_set(widget, false);
|
||||
@@ -122,7 +122,7 @@ void lf_rfid_workaround(void* p) {
|
||||
}
|
||||
|
||||
hal_pwmn_set(
|
||||
state->on ? 0.5 : 0.0, (float)(state->freq_khz * 1000), &htim15, TIM_CHANNEL_1);
|
||||
state->on ? 0.5 : 0.0, (float)(state->freq_khz * 1000), &LFRFID_TIM, LFRFID_CH);
|
||||
|
||||
if(!state->on) {
|
||||
em4100_emulation(emulation_data, pull_pin_record);
|
||||
|
Reference in New Issue
Block a user