Files @ 55ef914749dc
Branch filter:

Location: windsonde/Source/error.c

ethanzonca
Add bme280, add humidity field to aprs output. Seems to work well.
//
// Error: Provides a simple interface for asserting and checking errors
//

#include "error.h"
#include "stm32f0xx_hal.h"

#include <stdio.h>


volatile uint32_t err_reg;
volatile uint8_t num_errors_asserted = 0;

// Moderately detailed messages corresponding to each error enum
char *  error_message[] =
{
		"GPS off",
		"GPS checksum",

};

// Set the passed error flag
void error_assert(uint8_t errno)
{
	// Errno invalid: exceeds bit length of error register
	if(errno >= 32)
		return;

	// Set error flag
	err_reg |= (1<<errno);

	// Count how many errors have occurred
	num_errors_asserted++;

	// Dispatch error message over IRdA and/or debug port
#ifdef DEBUG_ERROUT_ENABLE
	char outbuf[256];
	snprintf(outbuf, 256, "Error: %s (no details)\r\n", error_message[errno]);
	usb_send(outbuf);
	ir_efs_send(outbuf);
#endif
}

// Set the passed error flag with details about the error
void error_assert_info(uint8_t errno, char* details)
{
	// Errno invalid: exceeds bit length of error register
	if(errno >= 32)
		return;

	// Set error flag
	err_reg |= (1<<errno);

	// Count how many errors have occurred
	num_errors_asserted++;

	// Dispatch error message over IRdA and/or debug port
#ifdef DEBUG_ERROUT_ENABLE
	char outbuf[256];
	snprintf(outbuf, 256, "Error: %s (%s)\r\n", error_message[errno], details);
	usb_send(outbuf);
	ir_efs_send(outbuf);
#endif
}

// Check if the passed error flag has been asserted
uint8_t error_check(uint8_t errno)
{
	return (err_reg & (1<<errno)) > 0;
}

// Return 1 if any error has occurred
uint8_t error_occurred(void)
{
	return err_reg > 0;
}

// Return the number of errors that have occurred
uint8_t error_count(void)
{
	return num_errors_asserted;
}

// vim:softtabstop=4 shiftwidth=4 expandtab