Blink f1 (#50)

* Fix target_f1 build

* restore build for F1 target

* change default LED pin state

* add real hw gif

Co-authored-by: Vadim Kaushan <admin@disasm.info>
This commit is contained in:
coreglitch 2020-08-26 14:43:18 +06:00 committed by GitHub
parent e7aa6caf0e
commit ab07bfb104
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 134 additions and 62 deletions

View File

@ -2,9 +2,9 @@
#include "cmsis_os.h"
#include <string.h>
#define DEBUG
// TODO: this file contains printf, that not implemented on uC target
#ifdef DEBUG
#ifdef FURI_DEBUG
#include <stdio.h>
#endif
@ -28,13 +28,13 @@ static FuriRecord* find_record(const char* name) {
}
bool furi_create(const char* name, void* value, size_t size) {
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURI] creating %s record\n", name);
#endif
if(current_buffer_idx >= MAX_RECORD_COUNT) {
// max record count exceed
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURI] max record count exceed\n");
#endif
return NULL;
@ -62,7 +62,7 @@ FuriRecordHandler furi_open(
FlipperRecordCallback value_callback,
FlipperRecordStateCallback state_callback
) {
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURI] opening %s record\n", name);
#endif
@ -71,7 +71,7 @@ FuriRecordHandler furi_open(
if(record == NULL) {
// cannot find record
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURI] cannot find record %s\n", name);
#endif
@ -91,7 +91,7 @@ FuriRecordHandler furi_open(
if(subscriber == NULL) {
// cannot add subscriber (full)
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURI] cannot add subscriber (full)\n");
#endif
@ -123,7 +123,7 @@ FuriRecordHandler furi_open(
void furi_close(FuriRecordHandler* handler) {
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURI] closing %s record\n", handler->record->name);
#endif
@ -163,7 +163,7 @@ void furi_give(FuriRecordHandler* handler) {
}
bool furi_read(FuriRecordHandler* handler, void* value, size_t size) {
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURI] read from %s\n", handler->record->name);
#endif
@ -183,7 +183,7 @@ bool furi_read(FuriRecordHandler* handler, void* value, size_t size) {
}
bool furi_write(FuriRecordHandler* handler, const void* value, size_t size) {
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURI] write to %s\n", handler->record->name);
#endif

View File

@ -1,9 +1,9 @@
#include "furi.h"
#include "cmsis_os.h"
#define DEBUG
// TODO: this file contains printf, that not implemented on uC target
#ifdef DEBUG
#ifdef FURI_DEBUG
#include <stdio.h>
#endif
@ -29,7 +29,7 @@ FuriApp* find_task(TaskHandle_t handler) {
}
FuriApp* furiac_start(FlipperApplication app, const char* name, void* param) {
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURIAC] start %s\n", name);
#endif
@ -37,7 +37,7 @@ FuriApp* furiac_start(FlipperApplication app, const char* name, void* param) {
if(current_buffer_idx >= MAX_TASK_COUNT) {
// max task count exceed
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURIAC] max task count exceed\n");
#endif
return NULL;
@ -67,7 +67,7 @@ FuriApp* furiac_start(FlipperApplication app, const char* name, void* param) {
}
bool furiac_kill(FuriApp* app) {
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURIAC] kill %s\n", app->name);
#endif
@ -90,14 +90,14 @@ void furiac_exit(void* param) {
// run prev
if(current_task != NULL) {
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURIAC] exit %s\n", current_task->name);
#endif
if(current_task->prev != NULL) {
furiac_start(current_task->prev, current_task->prev_name, param);
} else {
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURIAC] no prev\n");
#endif
}
@ -116,12 +116,12 @@ void furiac_switch(FlipperApplication app, char* name, void* param) {
FuriApp* current_task = find_task(xTaskGetCurrentTaskHandle());
if(current_task == NULL) {
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURIAC] no current task found\n");
#endif
}
#ifdef DEBUG
#ifdef FURI_DEBUG
printf("[FURIAC] switch %s to %s\n", current_task->name, name);
#endif

View File

@ -1,7 +1,7 @@
[PreviousGenFiles]
HeaderPath=/home/aanper/project/flipperzero/fw/target_prod/Inc
HeaderPath=/home/aanper/project/flipperzero/flipperzero-firmware-community/target_f1/Inc
HeaderFiles=FreeRTOSConfig.h;stm32l4xx_it.h;stm32l4xx_hal_conf.h;main.h;usb_device.h;usbd_conf.h;usbd_desc.h;usbd_cdc_if.h;
SourcePath=/home/aanper/project/flipperzero/fw/target_prod/Src
SourcePath=/home/aanper/project/flipperzero/flipperzero-firmware-community/target_f1/Src
SourceFiles=freertos.c;stm32l4xx_it.c;stm32l4xx_hal_msp.c;main.c;usb_device.c;usbd_conf.c;usbd_desc.c;usbd_cdc_if.c;
[PreviousLibFiles]

View File

@ -34,8 +34,14 @@ BUILD_DIR = build
######################################
# source
######################################
# C sources
C_SOURCES = \
C_SOURCES =
CPP_SOURCES =
ASM_SOURCES =
C_DEFS =
# Target
C_SOURCES += \
Src/main.c \
Src/freertos.c \
Src/stm32l4xx_it.c \
@ -89,14 +95,44 @@ Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \
Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c
# ASM sources
ASM_SOURCES = \
C_SOURCES += Src/flipper_hal.c
C_DEFS += \
-DUSE_HAL_DRIVER \
-DSTM32L476xx \
-DBUTON_INVERT=false \
-DDEBUG_UART=huart1
ASM_SOURCES += \
startup_stm32l476xx.s
CPP_SOURCES = ../app/app.cpp
# Core
C_SOURCES += ../app/write.c
C_SOURCES += Src/flipper_hal.c
CPP_SOURCES += ../core/app.cpp
C_SOURCES += ../core/debug.c
C_SOURCES += ../core/furi.c
C_SOURCES += ../core/furi_ac.c
# System applications
ifeq ($(TEST), 1)
C_SOURCES += ../applications/tests/furiac_test.c
C_SOURCES += ../applications/tests/furi_record_test.c
C_SOURCES += ../applications/tests/test_index.c
C_DEFS += -DTEST
endif
# Examples
ifeq ($(EXAMPLE_BLINK), 1)
C_SOURCES += ../applications/examples/blink.c
C_DEFS += -DEXAMPLE_BLINK
endif
# User application
# Add C_SOURCES +=, C_DEFS += or CPP_SOURCES += here
#######################################
# binaries
@ -139,13 +175,6 @@ MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
# AS defines
AS_DEFS =
# C defines
C_DEFS = \
-DUSE_HAL_DRIVER \
-DSTM32L476xx \
-DBUTON_INVERT=false \
-DDEBUG_UART=huart1
# AS includes
AS_INCLUDES = \
@ -196,6 +225,11 @@ LDFLAGS = $(MCU) -specs=nano.specs -specs=nosys.specs -T$(LDSCRIPT) $(LIBDIR) $(
# default action: build all
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
example_blink:
EXAMPLE_BLINK=1 make
test:
TEST=1 make
#######################################
# build the application

View File

@ -53,6 +53,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*---------------------------------------------------------------------------*/
#include <stdbool.h>
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
@ -1019,6 +1021,9 @@ osStatus osRecursiveMutexWait (osMutexId mutex_id, uint32_t millisec);
*/
uint32_t osSemaphoreGetCount(osSemaphoreId semaphore_id);
// FreeRTOS add-on
bool task_equal(TaskHandle_t a, TaskHandle_t b);
#ifdef __cplusplus
}
#endif

View File

@ -25,6 +25,7 @@
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdbool.h>
/* USER CODE END Includes */
@ -105,6 +106,11 @@ void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, Stack
/* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */
bool task_equal(TaskHandle_t a, TaskHandle_t b) {
if(a == NULL || b == NULL) return false;
return a == b;
}
/* USER CODE END Application */

View File

@ -680,15 +680,20 @@ static void MX_GPIO_Init(void)
__HAL_RCC_GPIOD_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, DISPLAY_DI_Pin|LED_RED_Pin|CC1101_CS_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOA, DISPLAY_DI_Pin|CC1101_CS_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, LED_BLUE_Pin|DISPLAY_RST_Pin|IR_TX_Pin|LED_GREEN_Pin
|DISPLAY_BACKLIGHT_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOB, LED_BLUE_Pin|LED_GREEN_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, DISPLAY_RST_Pin|IR_TX_Pin|DISPLAY_BACKLIGHT_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOC, VIBRO_Pin|DISPLAY_CS_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(LED_RED_GPIO_Port, LED_RED_Pin, GPIO_PIN_SET);
/*Configure GPIO pins : PC13 PC0 PC1 PC9 */
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
@ -757,7 +762,7 @@ static void MX_GPIO_Init(void)
GPIO_InitStruct.Pin = LED_RED_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
HAL_GPIO_Init(LED_RED_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : PD2 */

View File

@ -170,11 +170,12 @@ PA6.Locked=true
PA6.Signal=GPXTI6
PA7.Locked=true
PA7.Signal=GPIO_Analog
PA8.GPIOParameters=GPIO_Speed,GPIO_Label,GPIO_ModeDefaultOutputPP
PA8.GPIOParameters=GPIO_Speed,PinState,GPIO_Label,GPIO_ModeDefaultOutputPP
PA8.GPIO_Label=LED_RED
PA8.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_OD
PA8.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
PA8.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM
PA8.Locked=true
PA8.PinState=GPIO_PIN_SET
PA8.Signal=GPIO_Output
PA9.Locked=true
PA9.Mode=Asynchronous
@ -185,11 +186,12 @@ PB0.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING
PB0.GPIO_PuPd=GPIO_PULLDOWN
PB0.Locked=true
PB0.Signal=GPXTI0
PB1.GPIOParameters=GPIO_Speed,GPIO_Label,GPIO_ModeDefaultOutputPP
PB1.GPIOParameters=GPIO_Speed,PinState,GPIO_Label,GPIO_ModeDefaultOutputPP
PB1.GPIO_Label=LED_BLUE
PB1.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_OD
PB1.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM
PB1.Locked=true
PB1.PinState=GPIO_PIN_SET
PB1.Signal=GPIO_Output
PB10.GPIOParameters=GPIO_Label
PB10.GPIO_Label=DISPLAY_RST
@ -206,11 +208,12 @@ PB13.GPIO_Label=RFID_OUT
PB13.Locked=true
PB13.Mode=Output Compare1 CH1N
PB13.Signal=TIM15_CH1N
PB14.GPIOParameters=GPIO_Speed,GPIO_Label,GPIO_ModeDefaultOutputPP
PB14.GPIOParameters=GPIO_Speed,PinState,GPIO_Label,GPIO_ModeDefaultOutputPP
PB14.GPIO_Label=LED_GREEN
PB14.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_OD
PB14.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM
PB14.Locked=true
PB14.PinState=GPIO_PIN_SET
PB14.Signal=GPIO_Output
PB15.GPIOParameters=GPIO_Label
PB15.GPIO_Label=RFID_PULL
@ -339,8 +342,8 @@ ProjectManager.MainLocation=Src
ProjectManager.NoMain=false
ProjectManager.PreviousToolchain=
ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=flipperzero_l476.ioc
ProjectManager.ProjectName=flipperzero_l476
ProjectManager.ProjectFileName=flipperzero_f1.ioc
ProjectManager.ProjectName=flipperzero_f1
ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=Makefile
ProjectManager.ToolChainLocation=

View File

@ -19,27 +19,25 @@ BUILD_DIR = build
######################################
# source
######################################
# C sources
C_SOURCES = \
Src/main.c
C_SOURCES =
CPP_SOURCES =
C_DEFS =
CPP_SOURCES = ../core/app.cpp
# Target
# Core
C_SOURCES += ../core/debug.c
C_SOURCES += ../core/furi.c
C_SOURCES += ../core/furi_ac.c
C_SOURCES += Src/main.c
C_SOURCES += Src/flipper_hal.c
C_SOURCES += Src/lo_os.c
C_SOURCES += Src/lo_hal.c
# C defines
C_DEFS = \
-DUSE_HAL_DRIVER \
-DSTM32L476xx \
-DBUTON_INVERT=false \
-DDEBUG_UART=huart1
C_DEFS += -DFURI_DEBUG
# Core
CPP_SOURCES += ../core/app.cpp
C_SOURCES += ../core/debug.c
C_SOURCES += ../core/furi.c
C_SOURCES += ../core/furi_ac.c
# System applications
@ -50,13 +48,17 @@ C_SOURCES += ../applications/tests/test_index.c
C_DEFS += -DTEST
endif
# User application
# Examples
ifeq ($(EXAMPLE_BLINK), 1)
C_SOURCES += ../applications/examples/blink.c
C_DEFS += -DEXAMPLE_BLINK
endif
# User application
# Add C_SOURCES +=, C_DEFS += or CPP_SOURCES += here
#######################################
# binaries
#######################################

View File

@ -82,3 +82,17 @@ Linux version has no LED or GPIO, but we can see debug messages how state of GPI
![](https://github.com/Flipper-Zero/flipperzero-firmware-community/raw/master/wiki_static/application_examples/example_blink.gif)
_You also run found source of this example in `applications/examples/blink.c` and run by `docker-compose exec dev make -C target_lo example_blink`_
Build for Flipper (board F1):
`docker-compose exec dev make -C target_f1`
Upload to microcontroller:
`./target_f1/deploy.sh`
Blink!
![](https://github.com/Flipper-Zero/flipperzero-firmware-community/raw/master/wiki_static/application_examples/example_blink_hw.gif)
_You also compile by `docker-compose exec dev make -C target_f1 example_blink`_

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0901a507ea047af9945c27549dc1460d5552cfafcff27f646453d129030f23da
size 623188