furi playground

This commit is contained in:
aanper
2020-08-17 21:06:56 +03:00
parent ac6581f73d
commit 6bac2e6297
7 changed files with 0 additions and 0 deletions

24
core/app.cpp Normal file
View File

@@ -0,0 +1,24 @@
#include "flipper.h"
#include <stdio.h>
extern "C" {
FILE* get_debug();
}
extern "C" void app() {
FILE* debug_uart = get_debug();
fprintf(debug_uart, "hello Flipper!\n");
GpioPin red_led = {LED_RED_GPIO_Port, LED_RED_Pin};
app_gpio_init(red_led, GpioModeOutput);
while(1) {
delay(100);
app_gpio_write(red_led, true);
delay(100);
app_gpio_write(red_led, false);
}
}

20
core/flipper.h Normal file
View File

@@ -0,0 +1,20 @@
extern "C" {
#include "main.h"
#include "flipper_hal.h"
#include "cmsis_os.h"
}
// Arduino defines
#define pinMode app_gpio_init
#define digitalWrite app_gpio_write
#define digitalRead app_gpio_read
#define EEMEM
#define delayMicroseconds delay_us
#define delay osDelay
#define byte uint8_t
#define OUTPUT GpioModeOutput
#define INPUT GpioModeInput
#define LOW false
#define HIGH true

0
core/furi.c Normal file
View File

0
core/furi.h Normal file
View File

31
core/write.c Normal file
View File

@@ -0,0 +1,31 @@
#define _GNU_SOURCE
#include "main.h"
#include <stdio.h>
extern UART_HandleTypeDef DEBUG_UART;
ssize_t uart_write(void* cookie, const char * buffer, size_t size) {
if (buffer == 0) {
/*
* This means that we should flush internal buffers. Since we
* don't we just return. (Remember, "handle" == -1 means that all
* handles should be flushed.)
*/
return 0;
}
return (ssize_t)HAL_UART_Transmit(&DEBUG_UART, (uint8_t*)buffer, (uint16_t)size, HAL_MAX_DELAY);
}
FILE* get_debug() {
FILE* fp = fopencookie(NULL,"w+", (cookie_io_functions_t){
.read = NULL,
.write = uart_write,
.seek = NULL,
.close = NULL
});
setvbuf(fp, NULL, _IONBF, 0);
return fp;
}