Restored libc_integration and vcom port

vcom_init() is now executed from the new bspInit2_callback() function called from miosix's bsp.
miosix_update
Morgan Diepart 2024-07-27 23:23:37 +02:00 zatwierdzone przez silseva
rodzic 3135c8e1e8
commit 3c308f149d
5 zmienionych plików z 106 dodań i 3 usunięć

@ -1 +1 @@
Subproject commit 49b2965680afc759cdaafb9f232f62e7d7a7e1e1
Subproject commit fa5632de76db04fdf812bbea242cad0e1c1cf691

Wyświetl plik

@ -10,6 +10,7 @@ project('OpenRTX', ['c', 'cpp'],
##
openrtx_def = {}
#openrtx_def += {'ENABLE_STDIO' : ''} # Enable vcom input/output
##
## UI font configuration, only one uncommented at a time
@ -194,6 +195,7 @@ gdx_src = ['openrtx/src/core/xmodem.c',
##
stm32f405_src = ['platform/mcu/STM32F4xx/init.c',
'platform/mcu/STM32F4xx/libc_integration.cpp',
'platform/mcu/STM32F4xx/drivers/usb/usb_bsp.c',
'platform/mcu/STM32F4xx/drivers/usb/usb_core.c',
'platform/mcu/STM32F4xx/drivers/usb/usb_dcd.c',

Wyświetl plik

@ -27,11 +27,14 @@
* in NXP's CMSIS pack files. In this case, it will initialize the clock tree to
* full speed, that is, a system clock of 119.808 MHz.
*
* The SystemInitHook also sets the vector table offset.
* The SystemInitHook function sets the vector table offset.
*
* The bspInit2_callback function initializes VCOM if STDIO is enabled.
*/
#include "arch/cortexM4_nxpmk22/nxpmk22f51212_generic/interfaces-impl/arch_registers_impl.h"
#include "CMSIS/Device/NXP/MK22FN512xxx12/Include/system_MK22F51212.h"
#include "drivers/usb_vcom.h"
extern void (* const __Vectors[])();
@ -68,3 +71,10 @@ void SystemInitHook(void)
SCB->VTOR = (unsigned int)(&__Vectors); // Relocates ISR vector
}
void bspInit2_callback()
{
#ifdef ENABLE_STDIO
vcom_init();
#endif
}

Wyświetl plik

@ -19,11 +19,14 @@
* This file is mainly used to define the SystemInitHook function.
* This function is called at the end of the SystemInit function.
*
* The SystemInitHook sets the vector table offset.
* The SystemInitHook function sets the vector table offset
*
* The bspInit2_callback function initializes VCOM if STDIO is enabled.
*/
#include "arch/cortexM4_stm32f4/stm32f405_generic/interfaces-impl/arch_registers_impl.h"
#include "CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h"
#include <drivers/usb_vcom.h>
extern void (* const __Vectors[])();
@ -31,3 +34,10 @@ void SystemInitHook(void)
{
SCB->VTOR = (unsigned int)(&__Vectors); // Relocates ISR vector
}
void bspInit2_callback()
{
#ifdef ENABLE_STDIO
vcom_init();
#endif
}

Wyświetl plik

@ -0,0 +1,81 @@
/***************************************************************************
* Copyright (C) 2020 - 2023 by Silvano Seva IU2KWO *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, see <http://www.gnu.org/licenses/> *
***************************************************************************/
#include <stdio.h>
#include <reent.h>
#include "drivers/usb_vcom.h"
#include <filesystem/file_access.h>
using namespace std;
#ifdef __cplusplus
extern "C" {
#endif
/**
* \internal
* _write_r, write to a file
*/
int _write_r(struct _reent *ptr, int fd, const void *buf, size_t cnt)
{
#ifdef ENABLE_STDIO
if(fd == STDOUT_FILENO || fd == STDERR_FILENO)
{
return vcom_writeBlock(buf, cnt);
}
#else
(void) ptr;
(void) fd;
(void) buf;
(void) cnt;
#endif
/* If fd is not stdout or stderr */
ptr->_errno = EBADF;
return -1;
}
/**
* \internal
* _read_r, read from a file.
*/
int _read_r(struct _reent *ptr, int fd, void *buf, size_t cnt)
{
#ifdef ENABLE_STDIO
if(fd == STDIN_FILENO)
{
for(;;)
{
ssize_t r = vcom_readBlock(buf, cnt);
if((r < 0) || (r == (ssize_t)(cnt))) return r;
}
}
#else
(void) ptr;
(void) fd;
(void) buf;
(void) cnt;
#endif
/* If fd is not stdin */
ptr->_errno = EBADF;
return -1;
}
#ifdef __cplusplus
}
#endif