Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: platforms/stm/disco_fletch/src/fletch_entry.cc

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « platforms/stm/disco_fletch/src/fletch_entry.h ('k') | platforms/stm/disco_fletch/src/freertos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: platforms/stm/disco_fletch/src/fletch_entry.cc
diff --git a/platforms/stm/disco_fletch/src/fletch_entry.cc b/platforms/stm/disco_fletch/src/fletch_entry.cc
deleted file mode 100644
index f6667d3aef2b59b2912a742b1ac03c5e7b7299b2..0000000000000000000000000000000000000000
--- a/platforms/stm/disco_fletch/src/fletch_entry.cc
+++ /dev/null
@@ -1,146 +0,0 @@
-// Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE.md file.
-
-#include <stdlib.h>
-
-#include <cmsis_os.h>
-extern "C" {
- #include <lcd_log.h>
-}
-#include <stm32746g_discovery.h>
-#include <stm32746g_discovery_lcd.h>
-
-#include "include/fletch_api.h"
-#include "include/static_ffi.h"
-
-#include "platforms/stm/disco_fletch/src/fletch_entry.h"
-#include "platforms/stm/disco_fletch/src/page_allocator.h"
-#include "platforms/stm/disco_fletch/src/uart.h"
-#include "src/shared/utils.h"
-
-extern unsigned char _binary_snapshot_start;
-extern unsigned char _binary_snapshot_end;
-extern unsigned char _binary_snapshot_size;
-
-extern PageAllocator* page_allocator;
-
-Uart* uart;
-
-extern "C" size_t UartRead(uint8_t* buffer, size_t count) {
- return uart->Read(buffer, count);
-}
-
-extern "C" size_t UartWrite(uint8_t* buffer, size_t count) {
- return uart->Write(buffer, count);
-}
-
-extern "C" void LCDDrawLine(
- uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2) {
- // BSP_LCD_DrawLine takes uint16_t arguments.
- BSP_LCD_DrawLine(x1, y1, x2, y2);
-}
-
-// Implementation of write used from syscalls.c to redirect all printf
-// calls to the print interceptors.
-extern "C" int Write(int file, char *ptr, int len) {
- for (int i = 0; i < len; i++) {
- if (file == 2) {
- fletch::Print::Error("%c", *ptr++);
- } else {
- fletch::Print::Out("%c", *ptr++);
- }
- }
- return len;
-}
-
-FLETCH_EXPORT_TABLE_BEGIN
- FLETCH_EXPORT_TABLE_ENTRY("uart_read", UartRead)
- FLETCH_EXPORT_TABLE_ENTRY("uart_write", UartWrite)
- FLETCH_EXPORT_TABLE_ENTRY("lcd_height", BSP_LCD_GetYSize)
- FLETCH_EXPORT_TABLE_ENTRY("lcd_width", BSP_LCD_GetXSize)
- FLETCH_EXPORT_TABLE_ENTRY("lcd_clear", BSP_LCD_Clear)
- FLETCH_EXPORT_TABLE_ENTRY("lcd_draw_line", LCDDrawLine)
- FLETCH_EXPORT_TABLE_ENTRY("lcd_set_foreground_color", BSP_LCD_SetTextColor)
- FLETCH_EXPORT_TABLE_ENTRY("lcd_set_background_color", BSP_LCD_SetBackColor)
- FLETCH_EXPORT_TABLE_ENTRY("lcd_display_string", BSP_LCD_DisplayStringAt)
-FLETCH_EXPORT_TABLE_END
-
-// Run fletch on the linked in snapshot.
-void StartFletch(void const * argument) {
- fletch::Print::Out("Setup fletch\n");
- FletchSetup();
- fletch::Print::Out("Reading fletch snapshot\n");
- unsigned char *snapshot = &_binary_snapshot_start;
- int snapshot_size = reinterpret_cast<int>(&_binary_snapshot_size);
- FletchProgram program = FletchLoadSnapshot(snapshot, snapshot_size);
- fletch::Print::Out("Run fletch program\n");
- FletchRunMain(program);
- fletch::Print::Out("Fletch program exited\n");
-}
-
-void UartPrintIntercepter(const char* message, int out, void* data) {
- int len = strlen(message);
- for (int i = 0; i < len; i++) {
- if (message[i] == '\n') {
- uart->Write(reinterpret_cast<const uint8_t*>("\r"), 1);
- }
- uart->Write(reinterpret_cast<const uint8_t*>(message + i), 1);
- }
-}
-
-// LCDLogPutchar is defined by the STM LCD log utility
-// (Utilities/Log/lcd_log.c) by means of the macro definitions of
-// LCD_LOG_PUTCHAR in lcd_log_conf.h.
-extern "C" int LCDLogPutchar(int ch);
-void LCDPrintIntercepter(const char* message, int out, void* data) {
- int len = strlen(message);
- if (out == 3) {
- LCD_LineColor = LCD_COLOR_RED;
- } else {
- LCD_LineColor = LCD_COLOR_BLACK;
- }
- for (int i = 0; i < len; i++) {
- LCDLogPutchar(message[i]);
- }
-}
-
-// Main task entry point from FreeRTOS.
-void FletchEntry(void const * argument) {
- // Add an arena of the 8Mb of external memory.
- uint32_t ext_mem_arena =
- page_allocator->AddArena("ExtMem", 0xc0000000, 0x800000);
-
- // Initialize the LCD.
- size_t fb_bytes = (RK043FN48H_WIDTH * RK043FN48H_HEIGHT * 2);
- size_t fb_pages = page_allocator->PagesForBytes(fb_bytes);
- void* fb = page_allocator->AllocatePages(fb_pages, ext_mem_arena);
- BSP_LCD_Init();
- BSP_LCD_LayerDefaultInit(1, reinterpret_cast<uint32_t>(fb));
- BSP_LCD_SelectLayer(1);
- BSP_LCD_SetFont(&LCD_DEFAULT_FONT);
-
- // Initialize LCD Log module.
- LCD_LOG_Init();
- LCD_LOG_SetHeader(reinterpret_cast<uint8_t*>(const_cast<char*>("Fletch")));
- LCD_LOG_SetFooter(reinterpret_cast<uint8_t*>(const_cast<char*>(
- "STM32746G-Discovery")));
- FletchRegisterPrintInterceptor(LCDPrintIntercepter, NULL);
-
- // For now always start the UART.
- uart = new Uart();
- uart->Start();
-
- FletchRegisterPrintInterceptor(UartPrintIntercepter, NULL);
-
- // Always disable standard out, as this will cause infinite
- // recursion in the syscalls.c handling of write.
- fletch::Print::DisableStandardOutput();
-
- StartFletch(argument);
-
- // No more to do right now.
- for (;;) {
- osDelay(1);
- }
-}
« no previous file with comments | « platforms/stm/disco_fletch/src/fletch_entry.h ('k') | platforms/stm/disco_fletch/src/freertos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698