kopia lustrzana https://github.com/OpenRTX/OpenRTX
Adapted MK22 vcom sources to miosix kernel but not activating it. Reconfigured x86 emulator.
rodzic
a02b693843
commit
fb9d8afb6c
16
meson.build
16
meson.build
|
@ -104,13 +104,13 @@ mk22fn512_src = ['platform/mcu/MK22FN512xxx12/boot/startup.cpp',
|
||||||
'platform/mcu/MK22FN512xxx12/drivers/gpio.c',
|
'platform/mcu/MK22FN512xxx12/drivers/gpio.c',
|
||||||
'platform/mcu/MK22FN512xxx12/drivers/delays.cpp',
|
'platform/mcu/MK22FN512xxx12/drivers/delays.cpp',
|
||||||
'platform/mcu/MK22FN512xxx12/drivers/I2C0.c',
|
'platform/mcu/MK22FN512xxx12/drivers/I2C0.c',
|
||||||
# 'platform/mcu/MK22FN512xxx12/drivers/usb/usb_device_cdc_acm.c',
|
'platform/mcu/MK22FN512xxx12/drivers/usb/usb_device_cdc_acm.c',
|
||||||
# 'platform/mcu/MK22FN512xxx12/drivers/usb/usb_device_ch9.c',
|
'platform/mcu/MK22FN512xxx12/drivers/usb/usb_device_ch9.c',
|
||||||
# 'platform/mcu/MK22FN512xxx12/drivers/usb/usb_device_dci.c',
|
'platform/mcu/MK22FN512xxx12/drivers/usb/usb_device_dci.c',
|
||||||
# 'platform/mcu/MK22FN512xxx12/drivers/usb/usb_device_descriptor.c',
|
'platform/mcu/MK22FN512xxx12/drivers/usb/usb_device_descriptor.c',
|
||||||
# 'platform/mcu/MK22FN512xxx12/drivers/usb/usb_device_khci.c',
|
'platform/mcu/MK22FN512xxx12/drivers/usb/usb_device_khci.c',
|
||||||
# 'platform/mcu/MK22FN512xxx12/drivers/usb/usb_osa_bm.c',
|
'platform/mcu/MK22FN512xxx12/drivers/usb/usb_osa_bm.c',
|
||||||
# 'platform/mcu/MK22FN512xxx12/drivers/usb_vcom.c',
|
'platform/mcu/MK22FN512xxx12/drivers/usb_vcom.c',
|
||||||
'platform/mcu/CMSIS/Device/NXP/MK22FN512xxx12/Source/system_MK22F51212.c']
|
'platform/mcu/CMSIS/Device/NXP/MK22FN512xxx12/Source/system_MK22F51212.c']
|
||||||
|
|
||||||
mk22fn512_inc = ['platform/mcu/CMSIS/Include',
|
mk22fn512_inc = ['platform/mcu/CMSIS/Include',
|
||||||
|
@ -233,7 +233,7 @@ dm1801_def = def + mk22fn512_def + {'PLATFORM_DM1801': ''}
|
||||||
## Compilation defines
|
## Compilation defines
|
||||||
##
|
##
|
||||||
linux_c_args = []
|
linux_c_args = []
|
||||||
linux_l_args = ['--entry=entry', '-lm']
|
linux_l_args = ['-lm']
|
||||||
|
|
||||||
# Add AddressSanitizer if required
|
# Add AddressSanitizer if required
|
||||||
if get_option('asan')
|
if get_option('asan')
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <reent.h>
|
#include <reent.h>
|
||||||
#include "filesystem/file_access.h"
|
#include <usb_vcom.h>
|
||||||
|
#include <filesystem/file_access.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -31,11 +32,10 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
int _write_r(struct _reent *ptr, int fd, const void *buf, size_t cnt)
|
int _write_r(struct _reent *ptr, int fd, const void *buf, size_t cnt)
|
||||||
{
|
{
|
||||||
// if(fd == STDOUT_FILENO || fd == STDERR_FILENO)
|
if(fd == STDOUT_FILENO || fd == STDERR_FILENO)
|
||||||
// {
|
{
|
||||||
// vcom_writeBlock(buf, cnt);
|
return vcom_writeBlock(buf, cnt);
|
||||||
// return cnt;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
/* If fd is not stdout or stderr */
|
/* If fd is not stdout or stderr */
|
||||||
ptr->_errno = EBADF;
|
ptr->_errno = EBADF;
|
||||||
|
@ -48,19 +48,28 @@ int _write_r(struct _reent *ptr, int fd, const void *buf, size_t cnt)
|
||||||
*/
|
*/
|
||||||
int _read_r(struct _reent *ptr, int fd, void *buf, size_t cnt)
|
int _read_r(struct _reent *ptr, int fd, void *buf, size_t cnt)
|
||||||
{
|
{
|
||||||
// if(fd == STDIN_FILENO)
|
int ret = -1;
|
||||||
// {
|
|
||||||
// for(;;)
|
|
||||||
// {
|
|
||||||
// ssize_t r = vcom_readBlock(buf, cnt);
|
|
||||||
// if((r < 0) || (r == (ssize_t)(cnt))) return r;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
|
|
||||||
/* If fd is not stdin */
|
if(fd == STDIN_FILENO)
|
||||||
ptr->_errno = EBADF;
|
{
|
||||||
return -1;
|
for(;;)
|
||||||
|
{
|
||||||
|
ssize_t r = vcom_readBlock(buf, cnt);
|
||||||
|
if((r < 0) || (r == ((ssize_t) cnt)))
|
||||||
|
{
|
||||||
|
ret = ((int) r);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* If fd is not stdin */
|
||||||
|
ptr->_errno = EBADF;
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -619,7 +619,7 @@ void vcom_init()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NVIC_SetPriority(USB0_IRQn, 3);
|
NVIC_SetPriority(USB0_IRQn, 14);
|
||||||
NVIC_EnableIRQ(USB0_IRQn);
|
NVIC_EnableIRQ(USB0_IRQn);
|
||||||
|
|
||||||
USB_DeviceRun(cdcVcom.deviceHandle);
|
USB_DeviceRun(cdcVcom.deviceHandle);
|
||||||
|
|
|
@ -21,6 +21,10 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise USB virtual com port. Parameters: 115200 baud, 8N1.
|
* Initialise USB virtual com port. Parameters: 115200 baud, 8N1.
|
||||||
* @return zero on success, negative value on failure.
|
* @return zero on success, negative value on failure.
|
||||||
|
@ -45,4 +49,8 @@ ssize_t vcom_writeBlock(const void *buf, size_t len);
|
||||||
*/
|
*/
|
||||||
ssize_t vcom_readBlock(void *buf, size_t len);
|
ssize_t vcom_readBlock(void *buf, size_t len);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* USB_VCOM_H */
|
#endif /* USB_VCOM_H */
|
||||||
|
|
|
@ -27,9 +27,8 @@
|
||||||
|
|
||||||
radio_state Radio_State = {12, 8.2f, 3, 4, 1, false};
|
radio_state Radio_State = {12, 8.2f, 3, 4, 1, false};
|
||||||
|
|
||||||
void systemBootstrap();
|
int CLIMenu()
|
||||||
|
{
|
||||||
int CLIMenu() {
|
|
||||||
int choice = 0;
|
int choice = 0;
|
||||||
printf("Select the value to change:\n");
|
printf("Select the value to change:\n");
|
||||||
printf("1 -> RSSI\n");
|
printf("1 -> RSSI\n");
|
||||||
|
@ -41,20 +40,23 @@ int CLIMenu() {
|
||||||
printf("7 -> Print current state\n");
|
printf("7 -> Print current state\n");
|
||||||
printf("8 -> Exit\n");
|
printf("8 -> Exit\n");
|
||||||
printf("> ");
|
printf("> ");
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
scanf("%d", &choice);
|
scanf("%d", &choice);
|
||||||
} while (choice < 1 || choice > 8);
|
} while (choice < 1 || choice > 8);
|
||||||
printf("\033[1;1H\033[2J");
|
printf("\033[1;1H\033[2J");
|
||||||
return choice;
|
return choice;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateValue(float *curr_value) {
|
void updateValue(float *curr_value)
|
||||||
|
{
|
||||||
printf("Current value: %f\n", *curr_value);
|
printf("Current value: %f\n", *curr_value);
|
||||||
printf("New value: \n");
|
printf("New value: \n");
|
||||||
scanf("%f", curr_value);
|
scanf("%f", curr_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printState() {
|
void printState()
|
||||||
|
{
|
||||||
printf("\nCurrent state\n");
|
printf("\nCurrent state\n");
|
||||||
printf("RSSI : %f\n", Radio_State.RSSI);
|
printf("RSSI : %f\n", Radio_State.RSSI);
|
||||||
printf("Battery: %f\n", Radio_State.Vbat);
|
printf("Battery: %f\n", Radio_State.Vbat);
|
||||||
|
@ -65,16 +67,14 @@ void printState() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void *startRadio() {
|
void *startCLIMenu()
|
||||||
systemBootstrap();
|
{
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *startCLIMenu() {
|
|
||||||
int choice;
|
int choice;
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
choice = CLIMenu();
|
choice = CLIMenu();
|
||||||
switch (choice) {
|
switch (choice)
|
||||||
|
{
|
||||||
case VAL_RSSI:
|
case VAL_RSSI:
|
||||||
updateValue(&Radio_State.RSSI);
|
updateValue(&Radio_State.RSSI);
|
||||||
break;
|
break;
|
||||||
|
@ -100,48 +100,18 @@ void *startCLIMenu() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} while (choice != EXIT);
|
} while (choice != EXIT);
|
||||||
printf("exiting\n");
|
printf("73\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int emulator_main() {
|
void emulator_start()
|
||||||
pthread_t cli_thread, radio_thread;
|
{
|
||||||
int err1, err2 = 0;
|
pthread_t cli_thread;
|
||||||
|
int err = pthread_create(&cli_thread, NULL, startCLIMenu, NULL);
|
||||||
|
|
||||||
err1 = pthread_create(&cli_thread, NULL, startCLIMenu, NULL);
|
if(err)
|
||||||
err2 = pthread_create(&radio_thread, NULL, startRadio, NULL);
|
{
|
||||||
|
printf("An error occurred starting the emulator thread: %d\n", err);
|
||||||
if (err1 | err2) {
|
|
||||||
printf("An error occurred starting the threads: %d, %d\n", err1, err2);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
pthread_join(cli_thread, NULL);
|
|
||||||
|
|
||||||
printf("73\n");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void entry() {
|
|
||||||
__asm__(
|
|
||||||
"xorl %ebp, %ebp\n\t"
|
|
||||||
"mov %RDX, %R9\n\t"
|
|
||||||
|
|
||||||
#ifdef __ILP32__
|
|
||||||
"mov (%rsp), %esi\n\t"
|
|
||||||
"add $4, %esp\n\t"
|
|
||||||
#else
|
|
||||||
"popq %rsi\n\t"
|
|
||||||
#endif
|
|
||||||
"mov %RSP, %RDX\n\t"
|
|
||||||
"and $~15, %RSP\n\t"
|
|
||||||
"pushq %rax\n\t"
|
|
||||||
"pushq %rsp\n\t"
|
|
||||||
"mov __libc_csu_fini@GOTPCREL(%rip), %R8\n\t"
|
|
||||||
"mov __libc_csu_init@GOTPCREL(%rip), %RCX\n\t"
|
|
||||||
"mov emulator_main@GOTPCREL(%rip), %RDI\n\t"
|
|
||||||
"call *__libc_start_main@GOTPCREL(%rip)\n\t"
|
|
||||||
"hlt\n\t");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,8 @@
|
||||||
#define SCREEN_HEIGHT 128
|
#define SCREEN_HEIGHT 128
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum choices {
|
enum choices
|
||||||
|
{
|
||||||
VAL_RSSI=1,
|
VAL_RSSI=1,
|
||||||
VAL_BAT,
|
VAL_BAT,
|
||||||
VAL_MIC,
|
VAL_MIC,
|
||||||
|
@ -43,7 +44,8 @@ enum choices {
|
||||||
EXIT
|
EXIT
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
float RSSI;
|
float RSSI;
|
||||||
float Vbat;
|
float Vbat;
|
||||||
float micLevel;
|
float micLevel;
|
||||||
|
@ -54,4 +56,6 @@ typedef struct {
|
||||||
|
|
||||||
extern radio_state Radio_State;
|
extern radio_state Radio_State;
|
||||||
|
|
||||||
|
void emulator_start();
|
||||||
|
|
||||||
#endif /* EMULATOR_H */
|
#endif /* EMULATOR_H */
|
||||||
|
|
|
@ -29,6 +29,8 @@ void platform_init()
|
||||||
snprintf(hwInfo.name, 10, "Linux");
|
snprintf(hwInfo.name, 10, "Linux");
|
||||||
hwInfo.vhf_band = 1;
|
hwInfo.vhf_band = 1;
|
||||||
hwInfo.uhf_band = 1;
|
hwInfo.uhf_band = 1;
|
||||||
|
|
||||||
|
emulator_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void platform_terminate()
|
void platform_terminate()
|
||||||
|
|
Ładowanie…
Reference in New Issue