From 0739dca655d7daa706d43a38f83116c0736bcb23 Mon Sep 17 00:00:00 2001 From: Christos Choutouridis Date: Sun, 28 Jun 2020 22:08:01 +0300 Subject: [PATCH] Assignment 3: comment rework --- .../Libraries/drivers/NUCLEO_F401RE.c | 14 ++-- .../Libraries/drivers/NUCLEO_F401RE.h | 6 +- assignment_3/Libraries/drivers/alcd.c | 16 +---- assignment_3/Libraries/drivers/alcd.h | 16 +---- assignment_3/Libraries/drivers/deque08.c | 16 +---- assignment_3/Libraries/drivers/deque08.h | 16 +---- assignment_3/Libraries/drivers/driver_types.h | 16 +---- assignment_3/Libraries/drivers/hal.c | 50 ++++++++----- assignment_3/Libraries/drivers/hal.h | 16 +---- assignment_3/Libraries/drivers/jiffies.c | 18 +---- assignment_3/Libraries/drivers/jiffies.h | 18 +---- assignment_3/Libraries/drivers/onewire_uart.c | 16 +---- assignment_3/Libraries/drivers/onewire_uart.h | 16 +---- .../Libraries/drivers/thermostat_shield.c | 33 +++++++-- .../Libraries/drivers/thermostat_shield.h | 4 +- assignment_3/src/console.c | 18 +++-- assignment_3/src/console.h | 11 +-- assignment_3/src/main.c | 21 +++++- assignment_3/src/thermostat.h | 71 ++++++++++++------- 19 files changed, 177 insertions(+), 215 deletions(-) diff --git a/assignment_3/Libraries/drivers/NUCLEO_F401RE.c b/assignment_3/Libraries/drivers/NUCLEO_F401RE.c index e17993e..c004190 100644 --- a/assignment_3/Libraries/drivers/NUCLEO_F401RE.c +++ b/assignment_3/Libraries/drivers/NUCLEO_F401RE.c @@ -5,9 +5,8 @@ * Nucleo F401RE port file. This file contain the implementation of driver * calls for F401RE board. * - * Created on: May 23, 2020 - * Author: Christos Choutouridis AEM: 8997 - * email : + * Author: Christos Choutouridis AEM: 8997 + * email : */ #include "NUCLEO_F401RE.h" @@ -123,7 +122,14 @@ void HAL_Delay(uint32_t Delay) { /* * ================ Jiffies ====================== */ - +/*! + * Provide jiffy compatible set frequency functionality + * \param jf_freq The desire frequency + * \param jiffies The number of steps (jiffies) + * \return The status of the operation + * \arg 0 Success + * \arg 1 Fail + */ int JF_setfreq (uint32_t jf_freq, uint32_t jiffies) { uint32_t psc=0; diff --git a/assignment_3/Libraries/drivers/NUCLEO_F401RE.h b/assignment_3/Libraries/drivers/NUCLEO_F401RE.h index 4124271..1ca92a2 100644 --- a/assignment_3/Libraries/drivers/NUCLEO_F401RE.h +++ b/assignment_3/Libraries/drivers/NUCLEO_F401RE.h @@ -5,9 +5,8 @@ * Nucleo F401RE port file. This file contain the implementation of driver * calls for F401RE board. * - * Created on: May 23, 2020 - * Author: Christos Choutouridis AEM: 8997 - * email : + * Author: Christos Choutouridis AEM: 8997 + * email : */ #ifndef NUCLEO_F401RE_H_ @@ -28,7 +27,6 @@ typedef enum { }LLD_Status_en; typedef uint8_t din_t; -//typedef int adc_t; #define OFF (0) #define ON (!OFF) diff --git a/assignment_3/Libraries/drivers/alcd.c b/assignment_3/Libraries/drivers/alcd.c index b56f354..db086c5 100644 --- a/assignment_3/Libraries/drivers/alcd.c +++ b/assignment_3/Libraries/drivers/alcd.c @@ -3,20 +3,8 @@ * \brief * A target independent Alpharithmetic LCD driver * - * Copyright (C) 2014 Houtouridis Christos (http://www.houtouridis.net) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * Author: Christos Choutouridis AEM: 8997 + * email : * */ diff --git a/assignment_3/Libraries/drivers/alcd.h b/assignment_3/Libraries/drivers/alcd.h index a110b78..fb306e4 100644 --- a/assignment_3/Libraries/drivers/alcd.h +++ b/assignment_3/Libraries/drivers/alcd.h @@ -3,20 +3,8 @@ * \brief * A target independent Alpharithmetic LCD driver * - * Copyright (C) 2014 Christos Choutouridis (http://www.houtouridis.net) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * Author: Christos Choutouridis AEM: 8997 + * email : * */ diff --git a/assignment_3/Libraries/drivers/deque08.c b/assignment_3/Libraries/drivers/deque08.c index 0dfc608..324f858 100644 --- a/assignment_3/Libraries/drivers/deque08.c +++ b/assignment_3/Libraries/drivers/deque08.c @@ -3,20 +3,8 @@ * \brief * This file provides double ended queue capability based on a ring buffer * - * Copyright (C) 2014 Houtouridis Christos - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * Author: Christos Choutouridis AEM: 8997 + * email : * */ #include "deque08.h" diff --git a/assignment_3/Libraries/drivers/deque08.h b/assignment_3/Libraries/drivers/deque08.h index ba868da..1069c05 100644 --- a/assignment_3/Libraries/drivers/deque08.h +++ b/assignment_3/Libraries/drivers/deque08.h @@ -3,20 +3,8 @@ * \brief * This file provides double ended queue capability based on a ring buffer * - * Copyright (C) 2014 Houtouridis Christos - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * Author: Christos Choutouridis AEM: 8997 + * email : * */ #ifndef __deque08_h__ diff --git a/assignment_3/Libraries/drivers/driver_types.h b/assignment_3/Libraries/drivers/driver_types.h index dc1c5ed..68301f8 100644 --- a/assignment_3/Libraries/drivers/driver_types.h +++ b/assignment_3/Libraries/drivers/driver_types.h @@ -1,20 +1,8 @@ /*! * \file driver_types.h * - * Copyright (C) 2020 Choutouridis Christos - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * Author: Christos Choutouridis AEM: 8997 + * email : * */ diff --git a/assignment_3/Libraries/drivers/hal.c b/assignment_3/Libraries/drivers/hal.c index 58cd1fa..9e11f0a 100644 --- a/assignment_3/Libraries/drivers/hal.c +++ b/assignment_3/Libraries/drivers/hal.c @@ -1,20 +1,8 @@ /*! * \file hal.c * - * Copyright (C) 2020 Choutouridis Christos (http://www.houtouridis.net) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * Author: Christos Choutouridis AEM: 8997 + * email : * */ #include "hal.h" @@ -30,7 +18,6 @@ proximity_t prox; /*! * Initialize all hardware - * @return */ int hal_hw_init (void) { // Init base board @@ -67,14 +54,17 @@ void lcd_init (void) { alcd_init (&alcd, (alcd_funset_en)LCD_FUNSET_2L8); } +//! lcd enable wrapper __INLINE void lcd_enable (uint8_t en) { alcd_enable(&alcd, en); } +//!< lcd putchar wrapper __INLINE int lcd_putchar (char c) { return alcd_putchar(&alcd, c); } +//! lcd puts wrapper int lcd_puts (const char *s) { int i =0; while (alcd_putchar(&alcd, *s++)) @@ -91,6 +81,9 @@ __INLINE void led_green (uint8_t en) { LED_GREEN (en); } /* * ========= Relay =========== */ +/*! + * Create pulses to re-state reay coil + */ void relay (uint8_t on) { switch (on) { case 0: @@ -113,19 +106,23 @@ void relay (uint8_t on) { uint8_t ds18b20_rom[8]; uint8_t zero_rom[8] = {0}; +/*! + * Initialize temperature measurement system + */ int temp_init (uint8_t resolution) { if (!IS_TEMP_RESOLUTION(resolution)) return 1; + // link with hardware ow_uart_link_rw (&ow, (ow_uart_rw_ft)SHIELD_1W_RW); ow_uart_link_br (&ow, (ow_uart_br_ft)SHIELD_1W_UART_BR); ow_uart_set_timing (&ow, OW_UART_T_STANDARD); - ow_uart_init (&ow); - ow_uart_search(&ow, ds18b20_rom); + ow_uart_init (&ow); // init + ow_uart_search(&ow, ds18b20_rom);// do a search if (!memcmp ((const void*)ds18b20_rom, (const void*)zero_rom, 8)) - return 1; + return 1; // if there is no DS18b20 error // set resolution to 9-bit ow_uart_reset(&ow); @@ -138,6 +135,9 @@ int temp_init (uint8_t resolution) { return 0; } +/*! + * Temperature read functionality + */ float temp_read (void) { uint8_t t[2]; @@ -164,11 +164,22 @@ float temp_read (void) { /* * ========= Proximity =========== */ +/*! + * Initialize proximity system + * \param p Which proximity object to initialize + */ void proximity_init (proximity_t* p){ for (int i =0 ; ireadings[p->iter++] = (c_usec) ? ((t2 - t1)/c_usec) / 58.2 : PROX_MAX_DISTANSE; p->iter %= PROX_READINGS; - // Return filtered distance + // Return filtered distance (moving average filter FIR) ret =0; for (int i=0 ; ireadings[i]; diff --git a/assignment_3/Libraries/drivers/hal.h b/assignment_3/Libraries/drivers/hal.h index 9a98cfe..69433de 100644 --- a/assignment_3/Libraries/drivers/hal.h +++ b/assignment_3/Libraries/drivers/hal.h @@ -1,20 +1,8 @@ /*! * \file hal.h * - * Copyright (C) 2020 Choutouridis Christos (http://www.houtouridis.net) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * Author: Christos Choutouridis AEM: 8997 + * email : * */ #ifndef DRIVERS_HAL_H_ diff --git a/assignment_3/Libraries/drivers/jiffies.c b/assignment_3/Libraries/drivers/jiffies.c index ae38db1..77f78e0 100644 --- a/assignment_3/Libraries/drivers/jiffies.c +++ b/assignment_3/Libraries/drivers/jiffies.c @@ -1,22 +1,10 @@ -/* +/*! * \file jiffies.c * \brief * A target independent jiffy functionality * - * Copyright (C) 2014 Houtouridis Christos (http://www.houtouridis.net) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * Author: Christos Choutouridis AEM: 8997 + * email : * */ #include "jiffies.h" diff --git a/assignment_3/Libraries/drivers/jiffies.h b/assignment_3/Libraries/drivers/jiffies.h index af5a300..c2ec774 100644 --- a/assignment_3/Libraries/drivers/jiffies.h +++ b/assignment_3/Libraries/drivers/jiffies.h @@ -1,22 +1,10 @@ -/* +/*! * \file jiffies.h * \brief * A target independent jiffy functionality * - * Copyright (C) 2014 Houtouridis Christos (http://www.houtouridis.net) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * Author: Christos Choutouridis AEM: 8997 + * email : * */ #ifndef __jiffies_h__ diff --git a/assignment_3/Libraries/drivers/onewire_uart.c b/assignment_3/Libraries/drivers/onewire_uart.c index 5d799cb..eb1423c 100644 --- a/assignment_3/Libraries/drivers/onewire_uart.c +++ b/assignment_3/Libraries/drivers/onewire_uart.c @@ -4,20 +4,8 @@ * A target independent 1-wire implementation using a microprocessor's uart * for bit timing * - * Copyright (C) 2015 Choutouridis Christos (http://www.houtouridis.net) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * Author: Christos Choutouridis AEM: 8997 + * email : * */ #include "onewire_uart.h" diff --git a/assignment_3/Libraries/drivers/onewire_uart.h b/assignment_3/Libraries/drivers/onewire_uart.h index a8500de..42a6e99 100644 --- a/assignment_3/Libraries/drivers/onewire_uart.h +++ b/assignment_3/Libraries/drivers/onewire_uart.h @@ -12,20 +12,8 @@ * 3) A receive function even in blocking/polling mode * 4) A baudrate set function * - * Copyright (C) 2016 Choutouridis Christos - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser 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 Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * Author: Christos Choutouridis AEM: 8997 + * email : * */ #ifndef __onewire_uart_h__ diff --git a/assignment_3/Libraries/drivers/thermostat_shield.c b/assignment_3/Libraries/drivers/thermostat_shield.c index 2304fb5..7312b1e 100644 --- a/assignment_3/Libraries/drivers/thermostat_shield.c +++ b/assignment_3/Libraries/drivers/thermostat_shield.c @@ -5,8 +5,8 @@ * Nucleo thermostat shield port file. This file contain the implementation of driver * calls for the shield. * - * Author: Christos Choutouridis AEM: 8997 - * email : + * Author: Christos Choutouridis AEM: 8997 + * email : */ #include "thermostat_shield.h" @@ -29,6 +29,10 @@ static void SHIELD_SR04_Port_Init (void); * LCD_EN -- D14 -- PB9 * LCD_BL -- D2 -- PA10 */ + +/*! + * LCD pin Initialize + */ static void SHIELD_LCD_Port_Init (void) { GPIO_InitTypeDef GPIO_InitType; @@ -56,6 +60,10 @@ void SHIELD_LCD_BL (uint8_t en) { _DOUTx(GPIOA, GPIO_PIN_10, en); } * LED0 -- D4 -- PB5 * LED1 -- D3 -- PB3 */ + +/*! + * LED pin initialize + */ static void SHIELD_LED_Port_Init (void) { GPIO_InitTypeDef GPIO_InitType; @@ -74,6 +82,10 @@ void SHIELD_LED1 (uint8_t on) { _DOUTx(GPIOB, GPIO_PIN_3, on); } * BR1 -- D10 -- PB6 * BR2 -- D9 -- PC7 */ + +/*! + * H-Bridge pin initialize + */ static void SHIELD_BRIDGE_Port_Init (void) { GPIO_InitTypeDef GPIO_InitType; @@ -95,6 +107,10 @@ void SHIELD_BR2 (uint8_t on) { _DOUTx(GPIOC, GPIO_PIN_7, on); } * TRIG -- D11 -- PA7 * ECHO -- D12 -- PA6 */ + +/*! + * SR04 pin initialize + */ static void SHIELD_SR04_Port_Init (void) { GPIO_InitTypeDef GPIO_InitType; @@ -118,7 +134,7 @@ uint8_t SHIELD_ECHO (void) { return _DINx (GPIOA, GPIO_PIN_6); } * 1W_Tx -- PA11 (OD+PU) * 1W_Rx -- PA12 (I) */ -static UART_HandleTypeDef h1w_uart; +static UART_HandleTypeDef h1w_uart; //!< 1-wire uart handle /*! * \brief @@ -180,7 +196,7 @@ static LLD_Status_en _1W_UART_Init (void) { /*! - * Init the KEY 1wire interface and allocate all resources for it + * Init the 1wire interface and allocate all resources for it * \return The status of the operation * \arg LLD_OK Success * \arg LLD_ERROR The Init failed. @@ -308,6 +324,9 @@ uint8_t SHIELD_1W_Tx (uint8_t byte) { return 0; } +/*! + * Shield hardware initialization + */ LLD_Status_en SHIELD_Init (void) { SHIELD_LCD_Port_Init (); SHIELD_LED_Port_Init (); @@ -324,9 +343,9 @@ LLD_Status_en SHIELD_Init (void) { * COM_Tx -- PA2 (PP) * COM_Rx -- PA3 (I) */ -static UART_HandleTypeDef com_huart; -static deque08_t _com_rxq; -static byte_t _com_rxbuffer[COM_BUFFER_SIZE]; +static UART_HandleTypeDef com_huart; //!< com uart handle +static deque08_t _com_rxq; //!< deque object +static byte_t _com_rxbuffer[COM_BUFFER_SIZE]; //!< buffer for deque /*! * \brief diff --git a/assignment_3/Libraries/drivers/thermostat_shield.h b/assignment_3/Libraries/drivers/thermostat_shield.h index 7a6738e..26c0964 100644 --- a/assignment_3/Libraries/drivers/thermostat_shield.h +++ b/assignment_3/Libraries/drivers/thermostat_shield.h @@ -5,8 +5,8 @@ * Nucleo thermostat shield port file. This file contain the implementation of driver * calls for the shield. * - * Author: Christos Choutouridis AEM: 8997 - * email : + * Author: Christos Choutouridis AEM: 8997 + * email : */ #ifndef DRIVERS_THERMOSTAT_SHIELD_H_ diff --git a/assignment_3/src/console.c b/assignment_3/src/console.c index 3f1e0c9..8e9f7da 100644 --- a/assignment_3/src/console.c +++ b/assignment_3/src/console.c @@ -1,10 +1,11 @@ -/* - * console.c +/*! + * \file console.c + * \brief + * A simple serial console implementation for out thermostat * - * Created on: Jun 28, 2020 - * Author: hoo2 + * Author: Christos Choutouridis AEM: 8997 + * email : */ - #include "console.h" static char _buffer[COM_BUFFER_SIZE]; @@ -12,6 +13,10 @@ static int _cursor; static char _ans[512]; +/*! + * Parse and respond funcionality for serial console + * \param buffer Pointer to buffer + */ void parse (char* buffer) { int i; float_t s; @@ -102,6 +107,9 @@ void parse (char* buffer) { COM_Transmit((uint8_t*)_ans, i); } +/*! + * A simple terminal with echo + */ void console (void) { int ch; diff --git a/assignment_3/src/console.h b/assignment_3/src/console.h index 61e7c75..0125e08 100644 --- a/assignment_3/src/console.h +++ b/assignment_3/src/console.h @@ -1,10 +1,11 @@ -/* - * console.h +/*! + * \file console.h + * \brief + * A simple serial console implementation for out thermostat * - * Created on: Jun 28, 2020 - * Author: hoo2 + * Author: Christos Choutouridis AEM: 8997 + * email : */ - #ifndef CONSOLE_H_ #define CONSOLE_H_ diff --git a/assignment_3/src/main.c b/assignment_3/src/main.c index 4f27022..61add0a 100644 --- a/assignment_3/src/main.c +++ b/assignment_3/src/main.c @@ -27,6 +27,14 @@ float_t temp_get_current (void) { return (app_data.cur) ? app_data.T[app_data.cur-1] : app_data.T[MEASUREMENTS-1]; } +/*! + * Control functionality + * Handles: + * * Sensor reading + * * Temp averaging + * * Output calculation + * \note Non-blocking + */ void control (void) { static time_t sample =0; time_t now = time(0); // get time @@ -81,6 +89,11 @@ void control (void) { } } +/*! + * Display functionality + * Implement a state machine for lcd display + * \note Non-blocking + */ void display (void) { static time_t mark =0; @@ -151,6 +164,10 @@ void display (void) { lcd_puts(line2); } +/*! + * Set outputs + * \note Non-blocking + */ void outputs (void) { static uint8_t pr_output =0; @@ -166,7 +183,9 @@ void outputs (void) { } - +/* + * Main loop + */ int main(void) { hal_hw_init (); diff --git a/assignment_3/src/thermostat.h b/assignment_3/src/thermostat.h index a833292..91d602f 100644 --- a/assignment_3/src/thermostat.h +++ b/assignment_3/src/thermostat.h @@ -1,51 +1,67 @@ -/* - * thermostat.h +/*! + * \file thermostat.h + * \brief + * Application wide data type declarations * - * Created on: Jun 27, 2020 - * Author: hoo2 + * Author: Christos Choutouridis AEM: 8997 + * email : */ - #ifndef THERMOSTAT_H_ #define THERMOSTAT_H_ +/* + * Hard coded user settings + */ #define MEAS_WINDOW (120) // [sec] #define MEAS_INTERVAL (5) // [sec] #define MEASUREMENTS (MEAS_WINDOW / MEAS_INTERVAL) // keep this integer #define UI_AVERAGE_TIME (10) // [sec] //#define UI_USER_TIME (10) -typedef float float_t; -typedef int int_t; +typedef float float_t; //!< Select the floating point type for application +typedef int int_t; //!< Select the integer type for application + +/*! + * Thermostat mode enumerator + */ typedef enum { - HEATING =0, - COOLING + HEATING =0, //!< HEATING + COOLING //!< COOLING } mode_en; +/*! + * Application common data type + */ typedef struct { - float_t T[MEASUREMENTS]; - float_t Tav; - uint32_t cur; - uint8_t flag_output; - uint8_t flag_init; - uint8_t flag_proximity; - uint8_t signal_cycle; + float_t T[MEASUREMENTS]; //!< Temperature samples + float_t Tav; //!< Average temperature + uint32_t cur; //!< Cursor on sample array + uint8_t flag_output; //!< Momentary flag to indicate the relay state + uint8_t flag_init; //!< Momentary flag to indicate the end of initialization state + uint8_t flag_proximity; //!< Momentary flag to indicate that the user is near + uint8_t signal_cycle; //!< Acknolegable flag to indicate the end of measurement cycle } app_data_t; - +/*! + * Settings struct + */ typedef struct { - mode_en mode; - float_t Tset; - float_t Thyst; - float_t Pset; - float_t Physt; + mode_en mode; //!< Operational mode + float_t Tset; //!< Target temperature + float_t Thyst; //!< Target temperature hysteresis + float_t Pset; //!< Proximity distance + float_t Physt; //!< Proximity distance hysteresis } settings_t; +/*! + * User interface states + */ typedef enum { - ST_INIT =0, - ST_COUNT, - ST_AVERAGE, - ST_USER + ST_INIT =0, //!< ST_INIT: Still initializing + ST_COUNT, //!< ST_COUNT: Measurement cycle + ST_AVERAGE, //!< ST_AVERAGE: Display average + ST_USER //!< ST_USER: Display when a user is near } state_en; /* @@ -55,6 +71,9 @@ extern app_data_t app_data; extern state_en state; extern settings_t settings; +/*! + * Factory defaults + */ #define _Init_settings(s) s = { \ .mode = HEATING, \ .Tset = 21.0, \