From 605377db3fb1644ac1bdb5ae7f39bfe25d06d764 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 5 Dec 2013 00:34:47 +0000 Subject: added IHU subsystem (only 405 for now) git-svn-id: https://svn.spreadspace.org/mur.sat@856 7de4ea59-55d0-425e-a1af-a3118ea81d4c --- software/mpu/Makefile | 1 + software/mpu/board-F405/board.h | 14 ++++---- software/mpu/halconf.h | 2 +- software/mpu/ihu.c | 73 +++++++++++++++++++++++++++++++++++++++++ software/mpu/ihu.h | 39 ++++++++++++++++++++++ software/mpu/main.c | 6 ++-- software/mpu/mcuconf-F405.h | 2 +- software/mpu/usb-cdc-shell.c | 5 ++- 8 files changed, 128 insertions(+), 14 deletions(-) create mode 100644 software/mpu/ihu.c create mode 100644 software/mpu/ihu.h (limited to 'software') diff --git a/software/mpu/Makefile b/software/mpu/Makefile index 0b6e58f..92acc6b 100644 --- a/software/mpu/Makefile +++ b/software/mpu/Makefile @@ -108,6 +108,7 @@ CSRC = $(PORTSRC) \ $(CHIBIOS)/os/various/chprintf.c \ heartbeat.c \ usb-cdc-shell.c \ + ihu.c \ main.c # C++ sources that can be compiled in ARM or THUMB mode depending on the global diff --git a/software/mpu/board-F405/board.h b/software/mpu/board-F405/board.h index 60b6f3b..f1e2251 100644 --- a/software/mpu/board-F405/board.h +++ b/software/mpu/board-F405/board.h @@ -232,9 +232,9 @@ * GPIOA setup: * * PA0 - PIN0 (input pullup). - * PA0 - PIN1 (input pullup). - * PA0 - PIN2 (input pullup). - * PA0 - PIN3 (input pullup). + * PA1 - PIN1 (input pullup). + * PA2 - UART2_TX (alternate 7). + * PA3 - UART2_RX (alternate 7). * PA4 - PIN4 (input pullup). * PA5 - PIN5 (input pullup). * PA6 - PIN6 (input pullup). @@ -250,8 +250,8 @@ */ #define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_PIN0) | \ PIN_MODE_INPUT(GPIOA_PIN1) | \ - PIN_MODE_INPUT(GPIOA_PIN2) | \ - PIN_MODE_INPUT(GPIOA_PIN3) | \ + PIN_MODE_ALTERNATE(GPIOA_PIN2) | \ + PIN_MODE_ALTERNATE(GPIOA_PIN3) | \ PIN_MODE_INPUT(GPIOA_PIN4) | \ PIN_MODE_INPUT(GPIOA_PIN5) | \ PIN_MODE_INPUT(GPIOA_PIN6) | \ @@ -329,8 +329,8 @@ PIN_ODR_HIGH(GPIOA_PIN15)) #define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_PIN0, 0) | \ PIN_AFIO_AF(GPIOA_PIN1, 0) | \ - PIN_AFIO_AF(GPIOA_PIN2, 0) | \ - PIN_AFIO_AF(GPIOA_PIN3, 0) | \ + PIN_AFIO_AF(GPIOA_PIN2, 7) | \ + PIN_AFIO_AF(GPIOA_PIN3, 7) | \ PIN_AFIO_AF(GPIOA_PIN4, 0) | \ PIN_AFIO_AF(GPIOA_PIN5, 0) | \ PIN_AFIO_AF(GPIOA_PIN6, 0) | \ diff --git a/software/mpu/halconf.h b/software/mpu/halconf.h index 7b46cd2..3740179 100644 --- a/software/mpu/halconf.h +++ b/software/mpu/halconf.h @@ -125,7 +125,7 @@ * @brief Enables the SERIAL subsystem. */ #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL FALSE +#define HAL_USE_SERIAL TRUE #endif /** diff --git a/software/mpu/ihu.c b/software/mpu/ihu.c new file mode 100644 index 0000000..d18961c --- /dev/null +++ b/software/mpu/ihu.c @@ -0,0 +1,73 @@ +/* + * + * mur.sat + * + * Somewhen in the year 2012, mur.at will have a nano satellite launched + * into a low earth orbit (310 km above the surface of our planet). The + * satellite itself is a TubeSat personal satellite kit, developed and + * launched by interorbital systems. mur.sat is a joint venture of mur.at, + * ESC im Labor and realraum. + * + * Please visit the project hompage at sat.mur.at for further information. + * + * + * Copyright (C) 2013 Christian Pointner + * + * This file is part of mur.sat. + * + * mur.sat 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 + * any later version. + * + * mur.sat 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 mur.sat. If not, see . + * + */ + +#include "ch.h" +#include "hal.h" +#include "chprintf.h" + +#include "ihu.h" + +static Thread *tpIhuComm; +static WORKING_AREA(waIhuComm, 128); +static msg_t IhuComm(void *arg) +{ + BaseSequentialStream *chp = arg; + chRegSetThreadName("ihu-comm"); + + while (TRUE) { + char c; + if (chSequentialStreamRead(chp, (uint8_t *)&c, 1) == 0) + break; + + chprintf(chp, "got: '%c'\r\n", c); + } + return 0; /* Never executed.*/ +} + +static const SerialConfig sercfg = { + 57600, + 0, + USART_CR2_STOP1_BITS | USART_CR2_LINEN, + 0 +}; + +void ihuInit(void) +{ + sdStart(&SD2, &sercfg); + tpIhuComm = chThdCreateStatic(waIhuComm, sizeof(waIhuComm), NORMALPRIO, IhuComm, &SD2); +} + +void ihuStop(void) +{ + sdStop(&SD2); + chThdWait(tpIhuComm); +} diff --git a/software/mpu/ihu.h b/software/mpu/ihu.h new file mode 100644 index 0000000..b672cf0 --- /dev/null +++ b/software/mpu/ihu.h @@ -0,0 +1,39 @@ +/* + * + * mur.sat + * + * Somewhen in the year 2012, mur.at will have a nano satellite launched + * into a low earth orbit (310 km above the surface of our planet). The + * satellite itself is a TubeSat personal satellite kit, developed and + * launched by interorbital systems. mur.sat is a joint venture of mur.at, + * ESC im Labor and realraum. + * + * Please visit the project hompage at sat.mur.at for further information. + * + * + * Copyright (C) 2013 Christian Pointner + * + * This file is part of mur.sat. + * + * mur.sat 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 + * any later version. + * + * mur.sat 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 mur.sat. If not, see . + * + */ + +#ifndef MURSAT_ihu_h_INCLUDED +#define MURSAT_ihu_h_INCLUDED + +void ihuInit(void); +void ihuStop(void); + +#endif diff --git a/software/mpu/main.c b/software/mpu/main.c index 90c5ef9..d2bfdd9 100644 --- a/software/mpu/main.c +++ b/software/mpu/main.c @@ -36,6 +36,8 @@ #include "heartbeat.h" #include "usb-cdc-shell.h" +#include "ihu.h" + static void sysInit(void) { /* @@ -53,14 +55,14 @@ static void subsystemsInit(void) { /* call init functions of all subsystems which should spawn threads for their task */ heartbeatInit(); + ihuInit(); } static void subsystemsStop(void) { /* Safely stop critical threads, aka call shutdown functions of all subsystems */ /* -> invoke the xxxStop() method on all the active device drivers */ - - /* nothing here ... for now anyway */ + ihuStop(); } static void sysShutdown(void) diff --git a/software/mpu/mcuconf-F405.h b/software/mpu/mcuconf-F405.h index b60c7d9..596a3cb 100644 --- a/software/mpu/mcuconf-F405.h +++ b/software/mpu/mcuconf-F405.h @@ -207,7 +207,7 @@ * SERIAL driver system settings. */ #define STM32_SERIAL_USE_USART1 FALSE -#define STM32_SERIAL_USE_USART2 FALSE +#define STM32_SERIAL_USE_USART2 TRUE #define STM32_SERIAL_USE_USART3 FALSE #define STM32_SERIAL_USE_UART4 FALSE #define STM32_SERIAL_USE_UART5 FALSE diff --git a/software/mpu/usb-cdc-shell.c b/software/mpu/usb-cdc-shell.c index 7d9171a..245cc3a 100644 --- a/software/mpu/usb-cdc-shell.c +++ b/software/mpu/usb-cdc-shell.c @@ -61,7 +61,6 @@ #include "usb-cdc-shell.h" #include "usb-cdc-descriptor.h" - static SerialUSBDriver SDU1; /* @@ -243,10 +242,10 @@ static void cmd_flash(BaseSequentialStream *chp, int argc, char *argv[]) // TODO: prepare IHU chprintf(chp, "done\r\n"); } else if(!strcmp("ctr",argv[0])) { - // TODO: prepare IHU + // TODO: prepare CTR chprintf(chp, "done\r\n"); } else if(!strcmp("bat", argv[0])) { - // TODO: prepare IHU + // TODO: prepare BAT chprintf(chp, "done\r\n"); } else { chprintf(chp, "error: target unknown\r\n"); -- cgit v1.2.3