Changeset - 49485c1fefae
[Not reviewed]
cortex-f0
2 7 2
Ethan Zonca - 9 years ago 2015-08-23 19:00:35
ez@ethanzonca.com
Migrate sysclk, cleanup
9 files changed with 49 insertions and 49 deletions:
0 comments (0 inline, 0 general)
Makefile
Show inline comments
 
@@ -10,7 +10,7 @@
 

	
 

	
 
# SOURCES: list of sources in the user application
 
SOURCES = main.c usbd_conf.c usbd_cdc_if.c usb_device.c usbd_desc.c stm32f0xx_hal_msp.c stm32f0xx_it.c system_stm32f0xx.c gpio.c spi.c ssd1306.c stringhelpers.c display.c bootlib.c storage.c flash.c max31855.c
 
SOURCES = main.c usbd_conf.c usbd_cdc_if.c usb_device.c usbd_desc.c stm32f0xx_hal_msp.c stm32f0xx_it.c system_stm32f0xx.c gpio.c spi.c ssd1306.c stringhelpers.c display.c syslib.c storage.c flash.c max31855.c max31865.c
 

	
 
# TARGET: name of the user application
 
TARGET = main
config.h
Show inline comments
 
@@ -29,6 +29,9 @@
 

	
 
#define SSR_PIN GPIOA, GPIO_PIN_1
 

	
 
// Visual niceness
 
#define hal_init() HAL_Init()
 

	
 
#endif
 

	
 
// vim:softtabstop=4 shiftwidth=4 expandtab 
display.c
Show inline comments
 
@@ -4,7 +4,7 @@
 
#include "display.h"
 
#include "config.h"
 
#include "states.h"
 
#include "bootlib.h"
 
#include "syslib.h"
 
#include "flash.h"
 
#include "gpio.h"
 

	
main.c
Show inline comments
 
#include "stm32f0xx_hal.h"
 
 
#include "config.h"
 
#include "syslib.h"
 
#include "states.h"
 
#include "ssd1306.h"
 
#include "max31855.h"
 
@@ -16,14 +17,11 @@
 
 
 
// Prototypes
 
// Move to header file
 
void process();
 
void SystemClock_Config(void);
 
 
therm_settings_t set;
 
therm_status_t status;
 
 
 
// Globalish setting vars
 
SPI_HandleTypeDef hspi1;
 
static __IO uint32_t TimingDelay;
 
@@ -37,17 +35,19 @@ volatile int i=0;
 
int main(void)
 
{
 
 
    /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 
    HAL_Init();
 
    // Initialize HAL
 
    hal_init();
 
 
    /* Configure the system clock */
 
    SystemClock_Config();
 
    // Configure the system clock
 
    systemclock_config();
 
 
    /* Unset bootloader option bytes (if set) */
 
    // Unset bootloader option bytes (if set)
 
    void bootloader_unset(void);
 
 
    /* Initialize all configured peripherals */
 
    // Init GPIO
 
    init_gpio();
 
 
    // Init USB (TODO: Handle plugged/unplugged with external power)
 
    MX_USB_DEVICE_Init();
 
//    set.usb_plugged = 
 
 
@@ -55,15 +55,9 @@ int main(void)
 
    HAL_Delay(1000);
 
    HAL_GPIO_WritePin(LED_POWER, 1);
 
 
    // Enter into bootloader if up button pressed on boot
 
    if(!HAL_GPIO_ReadPin(SW_UP))
 
        bootloader_enter(); // Resets into bootloader
 
 
    // TODO: Awesome pwm of power LED 
 
 
    // Configure 1ms SysTick (change if more temporal resolution needed) 
 
    //RCC_ClocksTypeDef RCC_Clocks;
 
    //RCC_GetClocksFreq(&RCC_Clocks);
 
    //SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);
 
        bootloader_enter(); 
 
 
    // Init SPI busses
 
    init_spi();
 
@@ -121,33 +115,6 @@ int main(void)
 
 
}
 
 
// Clock configuration
 
void SystemClock_Config(void)
 
{
 
 
  RCC_OscInitTypeDef RCC_OscInitStruct;
 
  RCC_ClkInitTypeDef RCC_ClkInitStruct;
 
  RCC_PeriphCLKInitTypeDef PeriphClkInit;
 
 
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48;
 
  RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
 
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
 
  HAL_RCC_OscConfig(&RCC_OscInitStruct);
 
 
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
 
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI48;
 
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
 
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
 
  HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
 
 
  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
 
  PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
 
  HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
 
 
  __SYSCFG_CLK_ENABLE();
 
 
}
 
 
// PID implementation
 
// TODO: Make struct that has the last_temp and i_state in it, pass by ref. Make struct that has other input values maybe.
 
int16_t last_pid_temp = 0;
max31855.c
Show inline comments
 
@@ -91,4 +91,4 @@ void max31855_readtemp(SPI_HandleTypeDef
 
    }
 
}
 

	
 

	
 
// vim:softtabstop=4 shiftwidth=4 expandtab 
max31855.h
Show inline comments
 
@@ -4,3 +4,5 @@
 
void max31855_readtemp(SPI_HandleTypeDef* hspi1, therm_settings_t* set, therm_status_t* status);
 

	
 
#endif
 

	
 
// vim:softtabstop=4 shiftwidth=4 expandtab 
syslib.c
Show inline comments
 
file renamed from bootlib.c to syslib.c
 
@@ -61,3 +61,30 @@ void bootloader_enter(void) {
 
}
 

	
 

	
 
// Clock configuration
 
void systemclock_config(void)
 
{
 

	
 
  RCC_OscInitTypeDef RCC_OscInitStruct;
 
  RCC_ClkInitTypeDef RCC_ClkInitStruct;
 
  RCC_PeriphCLKInitTypeDef PeriphClkInit;
 

	
 
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48;
 
  RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
 
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
 
  HAL_RCC_OscConfig(&RCC_OscInitStruct);
 

	
 
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
 
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI48;
 
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
 
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
 
  HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1);
 

	
 
  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB;
 
  PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
 
  HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
 

	
 
  __SYSCFG_CLK_ENABLE();
 

	
 
}
 

	
syslib.h
Show inline comments
 
file renamed from bootlib.h to syslib.h
 
@@ -3,5 +3,6 @@
 

	
 
void bootloader_unset(void);
 
void bootloader_enter(void);
 
void systemclock_config(void);
 

	
 
#endif
usbd_conf.c
Show inline comments
 
@@ -53,7 +53,7 @@ PCD_HandleTypeDef hpcd_USB_FS;
 
static void SystemClockConfig_Resume(void);
 
/* USER CODE END 1 */
 
void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state);
 
extern void SystemClock_Config(void);
 
extern void systemclock_config(void);
 
 
/*******************************************************************************
 
		       LL Driver Callbacks (PCD -> USB Device Library)
 
@@ -502,7 +502,7 @@ void USBD_static_free(void *p)
 
  */
 
static void SystemClockConfig_Resume(void)
 
{
 
	SystemClock_Config();
 
	systemclock_config();
 
}
 
/* USER CODE END 4 */
 
0 comments (0 inline, 0 general)