64 lines
1.7 KiB
C
64 lines
1.7 KiB
C
#include <stdio.h>
|
|
|
|
#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();
|
|
}
|
|
|
|
}
|