Merge pull request #1 from ManoDaSilva/testing

Adding basic counting feature
pull/20/head
Manoel 2022-08-14 09:41:05 +02:00 zatwierdzone przez GitHub
commit 276ff8dac3
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
9 zmienionych plików z 44 dodań i 0 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
#include <string.h>
#include "horus_packet_v2.h"
#include "horus_common.h"
#include "config.h"
volatile uint16_t horus_v2_packet_counter = 0;
@ -67,6 +68,13 @@ size_t horus_packet_v2_create(uint8_t *payload, size_t length, telemetry_data *d
uint16_t ext_pressure_mbar = (uint16_t) (data->pressure_mbar_100 / 10.0f);
memcpy(custom_data_pointer, &ext_pressure_mbar, sizeof(ext_pressure_mbar));
// custom_data_pointer += sizeof(ext_pressure_mbar);
if (pulse_counter_enabled) {
// Unit: total counts
uint16_t ext_total_counts = (uint16_t) data->pulse_counts;
memcpy(custom_data_pointer, &ext_total_counts, sizeof(ext_total_counts));
}
horus_packet.Checksum = (uint16_t) calculate_crc16_checksum((char *) &horus_packet,
sizeof(horus_packet) - sizeof(horus_packet.Checksum));

Wyświetl plik

@ -44,6 +44,7 @@ bool leds_enabled = LEDS_ENABLE;
bool bmp280_enabled = SENSOR_BMP280_ENABLE;
bool si5351_enabled = RADIO_SI5351_ENABLE;
bool gps_nmea_output_enabled = GPS_NMEA_OUTPUT_VIA_SERIAL_PORT_ENABLE;
bool pulse_counter_enabled = PULSE_COUNTER_ENABLE;
volatile bool system_initialized = false;

Wyświetl plik

@ -55,6 +55,10 @@
#error GPS NMEA output via serial port cannot be enabled simultaneously with the I2C bus.
#endif
// Enable pulse counter (e.g. geiger counter) via external port header. This disables the use of I²C and Serial port as we use PB11-pin22 (expansion header, XDATA_RX).
// Also changes the HorusV2 data format and adds an additional field for total counts.
#define PULSE_COUNTER_ENABLE false
/**
* Built-in Si4032 radio chip transmission configuration
*/

Wyświetl plik

@ -19,6 +19,7 @@ extern bool leds_enabled;
extern bool gps_nmea_output_enabled;
extern bool bmp280_enabled;
extern bool si5351_enabled;
extern bool pulse_counter_enabled;
extern volatile bool system_initialized;

Wyświetl plik

@ -0,0 +1,13 @@
#include "pulse_counter.h"
bool pulse_counter_init()
{
//TODO: start interrupt handling, attach it to the designated pin.
return true;
}
uint16_t pulse_counter_get_counts(){
//TODO: Retrieve total counts and return it.
return 1666;
}

Wyświetl plik

@ -0,0 +1,5 @@
#include <stdint.h>
#include <stdbool.h>
bool pulse_counter_init();
uint16_t pulse_counter_get_counts();

Wyświetl plik

@ -7,6 +7,7 @@
#include "hal/datatimer.h"
#include "drivers/ubxg6010/ubxg6010.h"
#include "drivers/si4032/si4032.h"
#include "drivers/pulse_counter/pulse_counter.h"
#include "bmp280_handler.h"
#include "si5351_handler.h"
#include "radio.h"
@ -79,6 +80,11 @@ int main(void)
set_green_led(false);
set_red_led(true);
if (pulse_counter_enabled){
log_info("Pulse Counter Init");
pulse_counter_init();
}
if (gps_nmea_output_enabled) {
log_info("External USART init\n");

Wyświetl plik

@ -2,6 +2,7 @@
#include "hal/system.h"
#include "drivers/si4032/si4032.h"
#include "drivers/ubxg6010/ubxg6010.h"
#include "drivers/pulse_counter/pulse_counter.h"
#include "bmp280_handler.h"
#include "locator.h"
#include "config.h"
@ -18,6 +19,10 @@ void telemetry_collect(telemetry_data *data)
if (bmp280_enabled) {
bmp280_read_telemetry(data);
}
if (pulse_counter_enabled) {
data->pulse_counts=pulse_counter_get_counts();
}
ubxg6010_get_current_gps_data(&data->gps);

Wyświetl plik

@ -15,6 +15,7 @@ typedef struct _telemetry_data {
int32_t temperature_celsius_100;
uint32_t pressure_mbar_100;
uint32_t humidity_percentage_100;
uint16_t pulse_counts;
gps_data gps;