Changeset - 34a13647cf13
[Not reviewed]
default
0 4 0
Ethan Zonca (ethanzonca) - 9 years ago 2017-01-03 16:23:50
e@ethanzonca.com
Pressure reading now works! Needs pullups added...
4 files changed with 19 insertions and 3 deletions:
0 comments (0 inline, 0 general)
Include/system/stm32f0xx_hal_conf.h
Show inline comments
 
@@ -9,25 +9,25 @@
 
/**
 
  * @brief This is the list of modules to be used in the HAL driver 
 
  */
 
#define HAL_MODULE_ENABLED  
 
//#define HAL_ADC_MODULE_ENABLED
 
//#define HAL_CAN_MODULE_ENABLED   
 
//#define HAL_CEC_MODULE_ENABLED   
 
//#define HAL_COMP_MODULE_ENABLED   
 
//#define HAL_CRC_MODULE_ENABLED   
 
//#define HAL_CRYP_MODULE_ENABLED   
 
//#define HAL_TSC_MODULE_ENABLED   
 
//#define HAL_DAC_MODULE_ENABLED   
 
//#define HAL_I2C_MODULE_ENABLED
 
#define HAL_I2C_MODULE_ENABLED
 
//#define HAL_I2S_MODULE_ENABLED   
 
#define HAL_IWDG_MODULE_ENABLED
 
//#define HAL_LCD_MODULE_ENABLED   
 
//#define HAL_LPTIM_MODULE_ENABLED   
 
//#define HAL_RNG_MODULE_ENABLED   
 
//#define HAL_RTC_MODULE_ENABLED   
 
#define HAL_SPI_MODULE_ENABLED
 
#define HAL_TIM_MODULE_ENABLED
 
#define HAL_UART_MODULE_ENABLED
 
//#define HAL_USART_MODULE_ENABLED
 
//#define HAL_IRDA_MODULE_ENABLED   
 
//#define HAL_SMARTCARD_MODULE_ENABLED   
Libraries/aprs/aprs.c
Show inline comments
 
@@ -15,24 +15,25 @@
 
 *
 
 * You should have received a copy of the GNU Affero General Public License
 
 * along with FeatherHAB. If not, see <http://www.gnu.org/licenses/>.
 
 * 
 
 * Ethan Zonca
 
 *
 
 */
 

	
 
#include <string.h>
 
#include <stdlib.h>
 

	
 
#include "config.h"
 
#include "pressure.h"
 
#include "aprs.h"
 
#include "gps.h"
 
//#include "gps.h"
 
//#include "adc.h"
 
#include "ax25.h"
 

	
 

	
 
int32_t meters_to_feet(int32_t m)
 
{
 
  // 10000 ft = 3048 m
 
  return (float)m / 0.3048;
 
}
 
@@ -69,29 +70,29 @@ void aprs_send(void)
 
  snprintf(tmpBuffer, 128, "%ld,", gps_getdata()->longitude);
 
  ax25_send_string(tmpBuffer);
 

	
 
  // Speed
 
  snprintf(tmpBuffer, 128, "%d,", gps_getdata()->speed);
 
  ax25_send_string(tmpBuffer);
 

	
 
  // Altitude
 
  snprintf(tmpBuffer, 128, "%d,", gps_getdata()->altitude);
 
  ax25_send_string(tmpBuffer);
 

	
 
  // Pressure
 
  snprintf(tmpBuffer, 128, "%d,", 23);
 
  snprintf(tmpBuffer, 128, "%d,", pressure_getpressure());
 
  ax25_send_string(tmpBuffer);
 
  
 
  // Temperature
 
  snprintf(tmpBuffer, 128, "%d,", 77);
 
  snprintf(tmpBuffer, 128, "%d,", pressure_gettemp());
 
  ax25_send_string(tmpBuffer);
 

	
 
  // HDOP
 
  snprintf(tmpBuffer, 128, "%u,", gps_getdata()->pdop);
 
  ax25_send_string(tmpBuffer);
 

	
 

	
 
  ax25_send_footer();
 
  ax25_flush_frame();
 
}
 

	
 
// vim:softtabstop=4 shiftwidth=4 expandtab 
Source/main.c
Show inline comments
 
@@ -4,48 +4,51 @@
 
//
 
 
#include "config.h"
 
#include "error.h"
 
#include "system/gpio.h"
 
#include "system/sysclk.h"
 
#include "system/watchdog.h"
 
#include "system/uart.h"
 
#include "stm32f0xx_hal.h"
 
#include "si446x/si446x.h"
 
#include "aprs/aprs.h"
 
#include "aprs/afsk.h"
 
#include "pressure.h"
 
#include "gps.h"
 
 
 
int main(void)
 
{
 
  hal_init();
 
  sysclock_init();
 
  gpio_init();
 
 
 
  afsk_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)
 
		  pressure_read();
 
		  aprs_send();
 
		  //while(afsk_busy());
 
 
		  last_transmission = HAL_GetTick();
 
	  }
 
 
	  if(HAL_GetTick() - last_led > 100)
 
	  {
 
		  HAL_GPIO_TogglePin(LED_POWER);
 
		  last_led = HAL_GetTick();
 
	  }
 
Source/system/interrupts.c
Show inline comments
 
//
 
// Interrupts: ISRs for all global interrupts
 
//
 
 
#include <system/gpio.h>
 
#include <system/stm32f0xx_it.h>
 
#include "stm32f0xx_hal.h"
 
#include "stm32f0xx.h"
 
#include "system/gpio.h"
 
#include "aprs/afsk.h"
 
#include "pressure.h"
 
 
// Systick
 
void SysTick_Handler(void)
 
{
 
  HAL_IncTick();
 
  HAL_SYSTICK_IRQHandler();
 
}
 
 
 
void TIM1_CC_IRQHandler(void)
 
{
 
  HAL_TIM_IRQHandler(afsk_timer_gethandle());
 
}
 
 
void TIM1_BRK_UP_TRG_COM_IRQHandler(void)
 
{
 
  HAL_TIM_IRQHandler(afsk_timer_gethandle());
 
}
 
 
 
// Handle I2C interrupts
 
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());
 
	}
 
}
0 comments (0 inline, 0 general)