From 1d0fff3489e41ceef88c92d1406df346a66bdf90 Mon Sep 17 00:00:00 2001 From: Fred Date: Fri, 23 Oct 2020 09:51:29 +0200 Subject: [PATCH] Add platform files for linux build --- platform/mcu/x86_64/drivers/delays.c | 33 +++++++++++++++++ platform/mcu/x86_64/drivers/gpio.c | 54 ++++++++++++++++++++++++++++ platform/targets/linux/hwconfig.h | 29 +++++++++++++++ platform/targets/linux/platform.c | 34 ++++++++++++++++++ 4 files changed, 150 insertions(+) create mode 100644 platform/mcu/x86_64/drivers/delays.c create mode 100644 platform/mcu/x86_64/drivers/gpio.c create mode 100644 platform/targets/linux/hwconfig.h create mode 100644 platform/targets/linux/platform.c diff --git a/platform/mcu/x86_64/drivers/delays.c b/platform/mcu/x86_64/drivers/delays.c new file mode 100644 index 00000000..4949e6fb --- /dev/null +++ b/platform/mcu/x86_64/drivers/delays.c @@ -0,0 +1,33 @@ +/*************************************************************************** + * Copyright (C) 2020 by Frederik Saraci IU2NRO * + * * + * 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 * + ***************************************************************************/ + +#include "delays.h" +#include + +/** + * Implementation of the delay functions for x86_64. + */ + +void delayUs(unsigned int useconds) +{ + usleep(useconds); +} + +void delayMs(unsigned int mseconds) +{ + usleep(mseconds*1000); +} diff --git a/platform/mcu/x86_64/drivers/gpio.c b/platform/mcu/x86_64/drivers/gpio.c new file mode 100644 index 00000000..cb1c578b --- /dev/null +++ b/platform/mcu/x86_64/drivers/gpio.c @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2020 by Frederik Saraci IU2NRO * + * * + * 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 * + ***************************************************************************/ + +#include "gpio.h" + +void gpio_setMode(void *port, uint8_t pin, enum Mode mode) +{ + printf("gpio_setMode(%s, %u, %u)\n", (char*) port, pin, mode); +} + +void gpio_setAlternateFunction(void *port, uint8_t pin, uint8_t afNum) +{ + printf("gpio_setAlternateFunction(%s, %u, %u)\n", (char*) port, pin, afNum); +} + +void gpio_setOutputSpeed(void *port, uint8_t pin, enum Speed spd) +{ + printf("gpio_setOutputSpeed(%s, %u, %u)\n", (char*) port, pin, spd); +} + +void gpio_setPin(void *port, uint8_t pin) +{ + printf("gpio_setPin(%s, %u)\n", (char*) port, pin); +} + +void gpio_clearPin(void *port, uint8_t pin) +{ + printf("gpio_clearPin(%s, %u)\n", (char*) port, pin); +} + +void gpio_togglePin(void *port, uint8_t pin) +{ + printf("gpio_togglePin(%s, %u)\n", (char*) port, pin); +} + +uint8_t gpio_readPin(const void *port, uint8_t pin) +{ + printf("gpio_readPin(%s, %u)\n", (char*) port, pin); + return 1; +} diff --git a/platform/targets/linux/hwconfig.h b/platform/targets/linux/hwconfig.h new file mode 100644 index 00000000..0ce2ca8d --- /dev/null +++ b/platform/targets/linux/hwconfig.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * Copyright (C) 2020 by Frederik Saraci IU2NRO * + * * + * 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 * + ***************************************************************************/ + + +#define GPIOA "PA" +#define GPIOB "PB" +#define GPIOC "PC" +#define GPIOD "PD" +#define GPIOE "PE" +#define GPIOF "PF" +#define GPIOG "PG" +#define GPIOH "PH" +#define GPIOI "PI" +#define GPIOJ "PJ" +#define GPIOK "PK" \ No newline at end of file diff --git a/platform/targets/linux/platform.c b/platform/targets/linux/platform.c new file mode 100644 index 00000000..7f8ad736 --- /dev/null +++ b/platform/targets/linux/platform.c @@ -0,0 +1,34 @@ +/*************************************************************************** + * Copyright (C) 2020 by Frederik Saraci IU2NRO * + * * + * 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 * + ***************************************************************************/ + +#include "platform.h" +#include "gpio.h" + +void platform_init() +{ + printf("Platform init\n"); +} + +void platform_terminate() +{ + printf("Platform terminate\n"); +} + +void platform_setBacklightLevel(uint8_t level) +{ + printf("platform_setBacklightLevel(%u)\n", level); +}