Files @ d98fd1240e20
Branch filter:

Location: protofuse-firmware/src/main.c

NEO
fixed bug that caused all analogs to read same ADC value.
//
// STM32F103 Template Firmware
// Copyright 2016 SeaLandAire Technologies
// Author(s): Ethan Zonca
//

#include "stm32f3xx_hal.h"
#include "config.h"

#include "watchdog.h"
#include "system.h"
#include "gpio.h"
#include "error.h"
#include "flash.h"
#include "ssd1306.h"
#include "stdio.h"
#include "adc.h"
#include "dma.h"
#include "interrupts.h"
#include "buttons.h"

int main(void)
{
	sysclock_init();
	hal_init();
	gpio_init();
	ssd1306_init();
	ssd1306_drawlogo();
	ssd1306_clearscreen();
	adc_init();

	flash_init();
	watchdog_init();

	//just some example code for getting flash values
//	flash_getsettings()->values.can_id = 67;
//
//	if(flash_getsettings()->values.can_id == 12);

//	ssd1306_drawstring(const char *dataPtr, unsigned char row, unsigned char xPos)
//	ssd1306_drawstring("[ ProtoFuse ]", 0, 0);

	float temp_counter = 0;

	// Software timers
	uint32_t last_screen_update_time = HAL_GetTick();


	while (1)
	{
		// function that checks all the buttons
		freaking_debounce();

		// Grab and transmit data
		if(HAL_GetTick() - last_screen_update_time > 100)
		{
			char buffer[256];
			snprintf(buffer, 256, "Counter: %.1f", temp_counter);
			ssd1306_drawstring(buffer, 0, 0);
			snprintf(buffer, 256, "VBATT CNTS: %u", get_vbat_counts());
			ssd1306_drawstring(buffer, 1, 0);
			snprintf(buffer, 256, "IADC CNTS: %u", get_viout_counts());
			ssd1306_drawstring(buffer, 2, 0);
			snprintf(buffer, 256, "GIADC CNTS: %u", get_vgiout_counts());
			ssd1306_drawstring(buffer, 3, 0);



			temp_counter = temp_counter + 0.1;
			last_screen_update_time = HAL_GetTick();
		}

		watchdog_feed();
	}
}