Changeset - 2ee6c8e67f32
[Not reviewed]
Include/burn.h
Show inline comments
 
@@ -18,12 +18,14 @@ enum burn
 
 
enum burn_status
 
{
 
	BURN_IDLE = 0,
 
	BURN_BURNING,
 
};
 
 
 
void burn_queue(uint8_t burn_id, uint8_t delaytime, uint8_t resttime);
 
void burn_process(void);
 
 
#endif
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Include/config.h
Show inline comments
 
@@ -64,12 +64,14 @@
 
// is pathless. Uncomment the following two lines for WIDE2-1 path:
 
//#define DIGI_PATH1      "WIDE2"
 
//#define DIGI_PATH1_TTL  1
 
 
// Transmit the APRS sentence every X milliseconds
 
#define APRS_TRANSMIT_PERIOD 1000
 
 
 
 
 
 
#endif
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Include/error.h
Show inline comments
 
#ifndef ERROR_H
 
#define ERROR_H
 
#include "stm32f0xx_hal.h"
 
 
// Each error message has an enum entry
 
// If adding errors, remember to define a message for each in error.c
 
enum error_number
 
{
 
	ERR_RS485_PARSE = 0,
 
	ERR_GPS_OFF = 0,
 
	ERR_GPS_CHECKSUM,
 
};
 
 
 
void error_assert(uint8_t errno);
 
void error_assert_info(uint8_t errno, char* details);
 
uint8_t error_check(uint8_t errno);
 
uint8_t error_occurred(void);
 
uint8_t error_count(void);
 
 
#endif
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Include/gps.h
Show inline comments
 
@@ -33,12 +33,14 @@ uint8_t gps_check_nav(void);
 

	
 

	
 
void gps_poweron(void);
 
void gps_poweroff(void);
 

	
 
void gps_acquirefix(void);
 
uint8_t gps_getstate(void);
 

	
 
gps_data_t* gps_getdata(void);
 
uint8_t gps_ison(void);
 

	
 
#endif /* GPS_H_ */
 

	
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Include/pressure.h
Show inline comments
 
@@ -24,12 +24,13 @@
 
#define PRESSURE_CTRL1_PWRUP 0b10000000
 
 
void pressure_init(void);
 
void pressure_read(void);
 
void pressure_updatevalues(void);
 
 
int32_t pressure_gettemp(void);
 
int32_t pressure_getpressure(void);
 
 
I2C_HandleTypeDef* pressure_get_i2c_handle(void);
 
#endif
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Include/system/adc.h
Show inline comments
 
#ifndef SYSTEM_ADC_H_
 
#define SYSTEM_ADC_H_
 
 
void adc_init(void);
 
DMA_HandleTypeDef* adc__hdma_gethandle(void);
 
uint8_t adc_get_vbatt(void);
 
 
 
 
#endif /* SYSTEM_ADC_H_ */
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Include/system/flash.h
Show inline comments
 
@@ -35,12 +35,14 @@ typedef enum {FAILED = 0, PASSED = !FAIL
 
//------------------------------------------------------------------------------
 
// Prototypes
 
//------------------------------------------------------------------------------
 
void init_FLASH(void);
 
void flash_load(uint8_t flash_test);
 
void flash_erase(void);
 
void flash_read(void);
 
void flash_write(void);
 
void flash_checksum(void);
 
 
 
#endif // flash_h
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Include/system/gpio.h
Show inline comments
 
@@ -11,12 +11,14 @@
 
 
#define GPS_NOTEN_PORT GPIOA
 
#define GPS_NOTEN_PIN GPIO_PIN_1
 
#define GPS_NOTEN GPS_NOTEN_PORT , GPS_NOTEN_PIN
 
 
 
void gpio_init(void);
 
void gpio_schedule_shutdown(void);
 
void gpio_process_shutdown(void);
 
 
#endif
 
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Include/system/stm32f0xx_hal_conf.h
Show inline comments
 
@@ -253,12 +253,14 @@
 
  #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))
 
/* Exported functions ------------------------------------------------------- */
 
  void assert_failed(uint8_t* file, uint32_t line);
 
#else
 
  #define assert_param(expr) ((void)0)
 
#endif /* USE_FULL_ASSERT */    
 
    
 
#ifdef __cplusplus
 
}
 
#endif
 
 
#endif /* __STM32F0xx_HAL_CONF_H */
 
 
 // vim:softtabstop=4 shiftwidth=4 expandtab
Include/system/stm32f0xx_it.h
Show inline comments
 
@@ -3,12 +3,14 @@
 
 
#ifdef __cplusplus
 
 extern "C" {
 
#endif 
 
 
void SysTick_Handler(void);
 
 
#ifdef __cplusplus
 
}
 
#endif
 
 
#endif /* __STM32F0xx_IT_H */
 
 
 // vim:softtabstop=4 shiftwidth=4 expandtab
Include/system/sysclk.h
Show inline comments
 
#ifndef SYSCLK_H
 
#define SYSCLK_H
 
 
void sysclock_init(void);
 
 
#endif
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Include/system/uart.h
Show inline comments
 
#ifndef __usart_H
 
#define __usart_H
 
 
#include "stm32f0xx_hal.h"
 
 
void uart_init(void);
 
void uart_deinit(void);
 
UART_HandleTypeDef* uart_gethandle(void);
 
DMA_HandleTypeDef* uart_get_txdma_handle(void);
 
DMA_HandleTypeDef* uart_get_rxdma_handle(void);
 
 
#endif 
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Include/system/watchdog.h
Show inline comments
 
#ifndef WATCHDOG_H
 
#define WATCHDOG_H
 
 
void watchdog_init(void);
 
void watchdog_feed(void);
 
 
#endif
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Source/error.c
Show inline comments
 
@@ -5,25 +5,27 @@
 
#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[] =
 
{
 
		"RS485 parse fail",
 
		"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);
 
 
@@ -69,12 +71,14 @@ uint8_t error_check(uint8_t errno)
 
 
// 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
Source/gps.c
Show inline comments
 
//
 
// GPS: communicate with ublox GPS module via ubx protocol
 
//
 

	
 
#include "stm32f0xx_hal.h"
 

	
 
#include "config.h"
 
#include "error.h"
 
#include "system/gpio.h"
 
#include "system/uart.h"
 
#include "gps.h"
 

	
 

	
 
volatile gps_data_t position;
 
uint8_t gpson = 0;
 

	
 

	
 
// Private methods
 
static void gps_ubx_checksum(uint8_t* data, uint8_t len, uint8_t* cka, uint8_t* ckb);
 
static uint8_t _gps_verify_checksum(uint8_t* data, uint8_t len);
 

	
 

	
 
// Poll for fix data from the GPS and update the internal structure
 
void gps_update_data(void)
 
{
 
	// Error!
 
	if(!gpson)
 
	{
 
//		led_blink(5);
 
		error_assert(ERR_GPS_OFF);
 
		return;
 
	}
 

	
 
    // Construct the request to the GPS
 
    uint8_t request[8] = {0xB5, 0x62, 0x01, 0x07, 0x00, 0x00, 0xFF, 0xFF};
 

	
 

	
 
    volatile uint8_t check_a = 0;
 
    volatile uint8_t check_b = 0;
 
    for(uint8_t i = 2; i<6; i++)
 
    {
 
    	check_a += request[i];
 
@@ -45,27 +47,28 @@ void gps_update_data(void)
 
    volatile uint8_t flushed = uart_gethandle()->Instance->RDR;
 
    HAL_UART_Transmit(uart_gethandle(), request, 8, 100);
 

	
 

	
 

	
 
    // Get the message back from the GPS
 
    uint8_t buf[100];
 
    for(uint8_t i=0; i<100; i++)
 
    	buf[i] = 0xaa;
 
    volatile HAL_StatusTypeDef res = HAL_UART_Receive(uart_gethandle(), buf, 100, 3000);
 

	
 
    // Check 60 bytes minus SYNC and CHECKSUM (4 bytes)
 
//    if( !_gps_verify_checksum(&buf[2], 96) )
 
//        led_blink(2);
 

	
 
    if( !_gps_verify_checksum(&buf[2], 96) )
 
    {
 
		error_assert(ERR_GPS_CHECKSUM);
 
    }
 

	
 
    //volatile uint32_t gpstime_ms = (buf[6+0] << 24) | (buf[6+1] << 16) | buf[6+2] << 8) | (buf[6+3]);
 

	
 
    position.month = buf[6+6];
 
    position.day = buf[6+7];
 
    position.hour = buf[6+8];
 
    position.minute = buf[6+9];
 
    position.second = buf[6+10];
 
    position.valid = buf[6+11] & 0b1111;
 
    position.fixtype = buf[6+20];
 

	
 
    position.sats_in_solution = buf[6+23];
 
@@ -170,27 +173,24 @@ void gps_poweron(void)
 
//    // Enable power saving
 
//    uint8_t enable_powersave[10] = {0xB5, 0x62, 0x06, 0x11, 0x02, 0x00, 0x08, 0x01, 0x22, 0x92};
 
//    HAL_UART_Transmit(uart_gethandle(), enable_powersave, sizeof(enable_powersave)/sizeof(uint8_t), 100);
 
//	HAL_Delay(100);
 
//
 
//
 
//    // Set dynamic model 6 (<1g airborne platform)
 
//    uint8_t airborne_model[] = { 0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x05, 0x00, 0xFA, 0x00, 0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0xDC };
 
//    HAL_UART_Transmit(uart_gethandle(), airborne_model, sizeof(airborne_model)/sizeof(uint8_t), 100);
 
//	HAL_Delay(100);
 
//
 
//
 

	
 

	
 

	
 
    // Begin DMA reception
 
    //HAL_UART_Receive_DMA(uart_gethandle(), nmeaBuffer, NMEABUFFER_SIZE);
 

	
 
    gpson = 1;
 
}
 

	
 

	
 
// Power off GPS module
 
void gps_poweroff(void)
 
{
 
    // NOTE: pchannel
 
//	position.hour = 0;
Source/main.c
Show inline comments
 
@@ -34,33 +34,29 @@
 
#include "system/adc.h"
 
 
#include "si446x/si446x.h"
 
#include "aprs/aprs.h"
 
#include "aprs/afsk.h"
 
 
 
int main(void)
 
{
 
  hal_init();
 
  sysclock_init();
 
  gpio_init();
 
 
  adc_init();
 
 
  afsk_init();
 
  si446x_init();
 
  si446x_init();
 
 
  gps_poweron();
 
 
  pressure_init();
 
 
  // Software timers
 
  uint32_t last_transmission = HAL_GetTick();
 
  uint32_t last_led = HAL_GetTick();
 
 
  while (1)
 
  {
 
	  // Blink LEDs
 
	  if(HAL_GetTick() - last_transmission > 700)
 
	  {
 
		  gps_update_data(); // Will always return at 1hz rate (default measurement rate)
 
@@ -72,16 +68,18 @@ int main(void)
 
	  }
 
 
	  if(HAL_GetTick() - last_led > 100)
 
	  {
 
		  HAL_GPIO_TogglePin(LED_POWER);
 
		  last_led = HAL_GetTick();
 
	  }
 
 
	  if(afsk_request_cwoff())
 
		  si446x_cw_off();
 
 
	  // High-frequency function calls
 
//	  watchdog_feed();
 
	  watchdog_feed();
 
  }
 
}
 
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Source/pressure.c
Show inline comments
 
@@ -98,12 +98,14 @@ int32_t pressure_gettemp(void)
 
int32_t pressure_getpressure(void)
 
{
 
	return pressure_hPa;
 
}
 
 
 
 
inline I2C_HandleTypeDef* pressure_get_i2c_handle(void)
 
{
 
	return &hi2c1;
 
}
 
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Source/system/_sbrk.c
Show inline comments
 
@@ -11,12 +11,14 @@ static char *heap_end;
 
char *prev_heap_end;
 

	
 
if (heap_end == 0) {
 
heap_end = &end;
 
}
 

	
 
prev_heap_end = heap_end;
 

	
 
heap_end += incr;
 

	
 
return (caddr_t)prev_heap_end;
 
}
 

	
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Source/system/adc.c
Show inline comments
 
@@ -86,12 +86,14 @@ void adc_init(void)
 
 
}
 
 
uint8_t adc_get_vbatt(void)
 
{
 
	return adc_buffer[0] / 62.5; // tenths of volts ish
 
}
 
 
DMA_HandleTypeDef* adc__hdma_gethandle(void)
 
{
 
	return &hdma_adc;
 
}
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Source/system/flash.c
Show inline comments
 
@@ -221,12 +221,14 @@ void flash_erase(void)
 
	FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
 
 
	// Erase the FLASH pages
 
	for(EraseCounter = 0; (EraseCounter < NbrOfPage) && (FLASHStatus == FLASH_COMPLETE); EraseCounter++)
 
		FLASHStatus = FLASH_ErasePage(StartAddr + (PageSize * EraseCounter));
 
 
	FLASH_Lock();
 
 
	taskEXIT_CRITICAL();
 
}
 
*/
 
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Source/system/gpio.c
Show inline comments
 
@@ -50,12 +50,15 @@ void gpio_init(void)
 
 
  GPIO_InitStruct.Pin = GPS_NOTEN_PIN;
 
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
 
  GPIO_InitStruct.Pull = GPIO_NOPULL;
 
  GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
 
  HAL_GPIO_Init(GPS_NOTEN_PORT, &GPIO_InitStruct);
 
  HAL_GPIO_WritePin(GPS_NOTEN, 1); // yes, keep the chip disabled
 
 
 
  // Toggle the power LED
 
  HAL_GPIO_TogglePin(LED_POWER);
 
}
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
 
Source/system/interrupts.c
Show inline comments
 
@@ -35,12 +35,14 @@ void I2C1_IRQHandler(void)
 
{
 
	if (pressure_get_i2c_handle()->Instance->ISR & (I2C_FLAG_BERR | I2C_FLAG_ARLO | I2C_FLAG_OVR)) {
 
		HAL_I2C_ER_IRQHandler(pressure_get_i2c_handle());
 
	} else {
 
		HAL_I2C_EV_IRQHandler(pressure_get_i2c_handle());
 
	}
 
}
 
 
void DMA1_Channel1_IRQHandler(void)
 
{
 
  HAL_DMA_IRQHandler(adc__hdma_gethandle());
 
}
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Source/system/sysclk.c
Show inline comments
 
@@ -73,12 +73,14 @@ void sysclock_init(void)
 
	    /**Configure the Systick interrupt time
 
	    */
 
	  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
 
 
	    /**Configure the Systick
 
	    */
 
	  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
 
 
	  /* SysTick_IRQn interrupt configuration */
 
	  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
 
}
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
 
Source/system/uart.c
Show inline comments
 
@@ -108,12 +108,14 @@ UART_HandleTypeDef* uart_gethandle(void)
 
    return &huart1;
 
} 
 
 
DMA_HandleTypeDef* uart_get_txdma_handle(void)
 
{
 
    return &hdma_usart1_tx;
 
}
 
DMA_HandleTypeDef* uart_get_rxdma_handle(void)
 
{
 
    return &hdma_usart1_rx;
 
}
 
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Source/system/watchdog.c
Show inline comments
 
@@ -22,12 +22,14 @@ void watchdog_init(void)
 
	watchdog_feed();
 
	HAL_IWDG_Start(&hiwdg);
 
 
#endif
 
}
 
 
void watchdog_feed(void)
 
{
 
#ifdef WATCHDOG_ENABLE
 
	HAL_IWDG_Refresh(&hiwdg);
 
#endif
 
}
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
0 comments (0 inline, 0 general)