From 1c80fc10f6c82a122fcdd957663f082506ad8869 Mon Sep 17 00:00:00 2001 From: Joachim Steiger Date: Thu, 23 Nov 2023 22:04:37 +0100 Subject: [PATCH] add osmo-gtm900 subproject stub for rpi2040 on osmo gtm500 board --- osmo-gtm900/CMakeLists.txt | 11 +++++++ osmo-gtm900/osmo_gtm900.c | 63 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 osmo-gtm900/CMakeLists.txt create mode 100644 osmo-gtm900/osmo_gtm900.c diff --git a/osmo-gtm900/CMakeLists.txt b/osmo-gtm900/CMakeLists.txt new file mode 100644 index 0000000..b5ba4c3 --- /dev/null +++ b/osmo-gtm900/CMakeLists.txt @@ -0,0 +1,11 @@ +add_executable(osmo-gtm900) + +target_sources(osmo-gtm900 PRIVATE osmo_gtm900.c) + +target_link_libraries(osmo-gtm900 PRIVATE + pico_stdlib + ) + +pico_enable_stdio_usb(osmo-gtm900 1) + +pico_add_extra_outputs(osmo-gtm900) diff --git a/osmo-gtm900/osmo_gtm900.c b/osmo-gtm900/osmo_gtm900.c new file mode 100644 index 0000000..1d69bcd --- /dev/null +++ b/osmo-gtm900/osmo_gtm900.c @@ -0,0 +1,63 @@ +#include + +#include "pico/stdlib.h" +#include "hardware/uart.h" + +#include "tusb.h" + +#define GPIO_nMODEM_LDO_ON 14 /* pico pin 19 */ +#define GPIO_nPWON 6 /* pico pin 9 */ +#define GPIO_UART1_TX 0 /* pico pin 1 */ +#define GPIO_UART1_RX 1 /* pico pin 2 */ +#define GPIO_UART1_CTS 2 /* pico pin 4 */ +#define GPIO_UART1_RTS 3 /* pico pin 5 */ +#define GPIO_UART2_TX 4 /* pico pin 6 */ +#define GPIO_UART2_RX 5 /* pico pin 7 */ + + +int main() +{ + stdio_usb_init(); + + while (!tud_cdc_connected()) { + printf("."); + sleep_ms(500); + } + printf("Starting osmoGTM900 playground\n"); + + /* control lines as outputs */ + gpio_init(GPIO_nMODEM_LDO_ON); + gpio_pull_up(GPIO_nMODEM_LDO_ON); + gpio_set_dir(GPIO_nMODEM_LDO_ON, true); + gpio_put(GPIO_nMODEM_LDO_ON, 1); /* Make the GPIO Pin HIGH */ + /* no pullup on nPWON (already one in the modem) */ + gpio_init(GPIO_nPWON); + gpio_set_dir(GPIO_nPWON, true); + gpio_put(GPIO_nPWON, 1); + /* uarts as uarts */ + uart_init(uart0, 115200); + gpio_set_function(GPIO_UART1_TX, GPIO_FUNC_UART); + gpio_set_function(GPIO_UART1_RX, GPIO_FUNC_UART); + gpio_set_function(GPIO_UART1_CTS, GPIO_FUNC_UART); + gpio_set_function(GPIO_UART1_RTS, GPIO_FUNC_UART); + uart_init(uart1, 115200); + gpio_set_function(GPIO_UART2_TX, GPIO_FUNC_UART); + gpio_set_function(GPIO_UART2_RX, GPIO_FUNC_UART); + + printf("Entering main loop\n"); + sleep_ms(500); /* Delay of 500ms to settle usb */ + printf("Enabling modem power\n"); + gpio_put(GPIO_nMODEM_LDO_ON, 0); /* LOW */ + sleep_ms(500); /* delay to settle modem */ + /* power on modem by simulating button press*/ + printf("Resetting modem... "); + gpio_put(GPIO_nPWON, 0); + sleep_ms(200); + gpio_put(GPIO_nPWON, 1); + printf("done\n"); + + while (true) { +// usb-uart handling goes here(); + } + +}