Changeset - 2ee6c8e67f32
[Not reviewed]
Include/burn.h
Show inline comments
 
@@ -24,6 +24,8 @@ enum burn_status
 
 
 
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
 
@@ -70,6 +70,8 @@
 
 
 
 
 
 
#endif
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Include/error.h
Show inline comments
 
@@ -3,17 +3,20 @@
 
#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
 
@@ -39,6 +39,8 @@ 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
 
@@ -30,6 +30,7 @@ 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
 
@@ -5,6 +5,8 @@ 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
 
@@ -41,6 +41,8 @@ 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
 
@@ -17,6 +17,8 @@
 
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
 
@@ -259,6 +259,8 @@
 
    
 
#ifdef __cplusplus
 
}
 
#endif
 
 
#endif /* __STM32F0xx_HAL_CONF_H */
 
 
 // vim:softtabstop=4 shiftwidth=4 expandtab
Include/system/stm32f0xx_it.h
Show inline comments
 
@@ -9,6 +9,8 @@ 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
 
@@ -7,6 +7,8 @@ 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
 
@@ -2,6 +2,8 @@
 
#define WATCHDOG_H
 
 
void watchdog_init(void);
 
void watchdog_feed(void);
 
 
#endif
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Source/error.c
Show inline comments
 
@@ -11,13 +11,15 @@
 
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
 
@@ -75,6 +77,8 @@ uint8_t error_occurred(void)
 
 
// 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
 
@@ -2,32 +2,34 @@
 
// 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};
 

	
 
@@ -51,15 +53,16 @@ void gps_update_data(void)
 
    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];
 
@@ -176,15 +179,12 @@ void gps_poweron(void)
 
//    // 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;
 
}
 

	
Source/main.c
Show inline comments
 
@@ -40,21 +40,17 @@
 
 
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();
 
 
@@ -78,10 +74,12 @@ int main(void)
 
	  }
 
 
	  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
 
@@ -104,6 +104,8 @@ int32_t pressure_getpressure(void)
 
 
inline I2C_HandleTypeDef* pressure_get_i2c_handle(void)
 
{
 
	return &hi2c1;
 
}
 
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Source/system/_sbrk.c
Show inline comments
 
@@ -17,6 +17,8 @@ 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
 
@@ -92,6 +92,8 @@ uint8_t adc_get_vbatt(void)
 
}
 
 
DMA_HandleTypeDef* adc__hdma_gethandle(void)
 
{
 
	return &hdma_adc;
 
}
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Source/system/flash.c
Show inline comments
 
@@ -227,6 +227,8 @@ void flash_erase(void)
 
	FLASH_Lock();
 
 
	taskEXIT_CRITICAL();
 
}
 
*/
 
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Source/system/gpio.c
Show inline comments
 
@@ -56,6 +56,9 @@ void gpio_init(void)
 
  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
 
@@ -41,6 +41,8 @@ void I2C1_IRQHandler(void)
 
}
 
 
void DMA1_Channel1_IRQHandler(void)
 
{
 
  HAL_DMA_IRQHandler(adc__hdma_gethandle());
 
}
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Source/system/sysclk.c
Show inline comments
 
@@ -79,6 +79,8 @@ void sysclock_init(void)
 
	  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
 
@@ -114,6 +114,8 @@ DMA_HandleTypeDef* uart_get_txdma_handle
 
}
 
DMA_HandleTypeDef* uart_get_rxdma_handle(void)
 
{
 
    return &hdma_usart1_rx;
 
}
 
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
Source/system/watchdog.c
Show inline comments
 
@@ -28,6 +28,8 @@ void watchdog_init(void)
 
void watchdog_feed(void)
 
{
 
#ifdef WATCHDOG_ENABLE
 
	HAL_IWDG_Refresh(&hiwdg);
 
#endif
 
}
 
 
// vim:softtabstop=4 shiftwidth=4 expandtab
0 comments (0 inline, 0 general)