ECE 486 Support Libraries
init486.c File Reference

Processor configuration routines to support ECE 486. More...

#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "stm32l4xx_hal.h"
#include "stm32l476g_discovery.h"
#include "stm32l476g_discovery_glass_lcd.h"
#include "sample486.h"
#include "init486.h"
#include "err486.h"
#include "usart.h"
#include "opamp486.h"

Go to the source code of this file.

Functions

static void blinkandwait (void)
 Wait for a button-press while blinking the LEDs. More...
 
static void ece_486_deinit (void)
 
static void SystemClock_Config_MSI (void)
 System Clock Configuration. More...
 
static void SystemClock_Config_HSE (void)
 Hummels Config to give 80 MHz SYSCLK, with PLL48M1CLK=48 MHz The system Clock is configured as follows : System Clock source = PLL (HSE) SYSCLK(Hz) = 80000000 HCLK(Hz) = 80000000 AHB Prescaler = 1 APB1 Prescaler = 1 APB2 Prescaler = 1 HSE Frequency(Hz) = 8000000 (8 MHz external reference expected) PLL_M = 1 PLL_N = 20 PLL_R = 2 ( SYSCLK = PLLCLK = (8MHz)*N/M/R = 80 MHz ) PLL_P = 7 (No reason for this...) PLL_Q = 5 ( PLL48M1CLK = (16MHz)(N/M/Q) = 32 MHz !?! ) Flash Latency(WS) = 4. More...
 
static void init_dac (uint16_t fs, enum Num_Channels_Out chanout)
 
static void init_adc (uint16_t fs, enum Num_Channels_In chanin)
 
static void TIM4_Config (uint16_t fs)
 
static void config_digital_io (void)
 Configure a digital output pin. More...
 
static void config_pushbutton (void)
 Configure PA6 (Joystic Center) generate an interrupt. More...
 
static HAL_StatusTypeDef Hacked_HAL_DAC_DualStart_DMA (DAC_HandleTypeDef *hdac, uint32_t *pData, uint32_t Length)
 
void initialize (uint16_t fs, enum Num_Channels_In chanin, enum Num_Channels_Out chanout)
 Wrapper function to perform all processor initialization for ECE 486. More...
 
void initialize_ece486 (uint16_t fs, enum Num_Channels_In chanin, enum Num_Channels_Out chanout, enum Clock_Reference clkref)
 Wrapper function to perform all processor initialization for ECE 486. More...
 
float getsamplingfrequency (void)
 Simple function to return the best guess at the actual sampling frequency. More...
 
void HAL_DAC_MspInit (DAC_HandleTypeDef *hdac)
 
void HAL_DAC_MspDeInit (DAC_HandleTypeDef *hdac)
 
void HAL_TIM_Base_MspInit (TIM_HandleTypeDef *htim)
 
void HAL_TIM_Base_MspDeInit (TIM_HandleTypeDef *htim)
 
void HAL_ADC_MspInit (ADC_HandleTypeDef *hadc)
 
void HAL_ADC_MspDeInit (ADC_HandleTypeDef *hadc)
 
void DMA2_Channel5_IRQHandler (void)
 
void TIM6_DAC_IRQHandler (void)
 
void ADC1_2_IRQHandler (void)
 
void DMA1_Channel1_IRQHandler (void)
 
void SysTick_Handler (void)
 
void EXTI0_IRQHandler (void)
 
void EXTI1_IRQHandler (void)
 
void EXTI2_IRQHandler (void)
 
void EXTI3_IRQHandler (void)
 
void EXTI9_5_IRQHandler (void)
 
void HAL_GPIO_EXTI_Callback (uint16_t GPIO_Pin)
 

Variables

static DAC_HandleTypeDef DacHandle
 
static ADC_HandleTypeDef AdcHandle
 
static ADC_HandleTypeDef AdcHandle2
 
static float Actual_Sampling_Frequency
 
JOYState_TypeDef JoyState = JOY_NONE
 
__IO FlagStatus KeyPressed = RESET
 
enum Num_Channels_Out Output_Configuration
 
enum Num_Channels_In Input_Configuration
 

Detailed Description

Processor configuration routines to support ECE 486.

Author
Don Hummels
Date
Jan 2016

Definition in file init486.c.

Function Documentation

void ADC1_2_IRQHandler ( void  )

Definition at line 882 of file init486.c.

static void blinkandwait ( void  )
static

Wait for a button-press while blinking the LEDs.

Parameters
None
Return values
None

Definition at line 417 of file init486.c.

static void config_digital_io ( void  )
static

Configure a digital output pin.

Parameters
None
Return values
None

Definition at line 358 of file init486.c.

static void config_pushbutton ( void  )
static

Configure PA6 (Joystic Center) generate an interrupt.

Parameters
None
Return values
None

Definition at line 395 of file init486.c.

void DMA1_Channel1_IRQHandler ( void  )

Definition at line 891 of file init486.c.

void DMA2_Channel5_IRQHandler ( void  )

Definition at line 872 of file init486.c.

static void ece_486_deinit ( void  )
static

Definition at line 329 of file init486.c.

void EXTI0_IRQHandler ( void  )

Definition at line 913 of file init486.c.

void EXTI1_IRQHandler ( void  )

Definition at line 918 of file init486.c.

void EXTI2_IRQHandler ( void  )

Definition at line 923 of file init486.c.

void EXTI3_IRQHandler ( void  )

Definition at line 928 of file init486.c.

void EXTI9_5_IRQHandler ( void  )

Definition at line 933 of file init486.c.

static HAL_StatusTypeDef Hacked_HAL_DAC_DualStart_DMA ( DAC_HandleTypeDef *  hdac,
uint32_t *  pData,
uint32_t  Length 
)
static

Definition at line 525 of file init486.c.

void HAL_ADC_MspDeInit ( ADC_HandleTypeDef *  hadc)

Definition at line 853 of file init486.c.

void HAL_ADC_MspInit ( ADC_HandleTypeDef *  hadc)

Definition at line 789 of file init486.c.

void HAL_DAC_MspDeInit ( DAC_HandleTypeDef *  hdac)

Definition at line 616 of file init486.c.

void HAL_DAC_MspInit ( DAC_HandleTypeDef *  hdac)

Definition at line 571 of file init486.c.

void HAL_GPIO_EXTI_Callback ( uint16_t  GPIO_Pin)

Definition at line 938 of file init486.c.

void HAL_TIM_Base_MspDeInit ( TIM_HandleTypeDef *  htim)

Definition at line 644 of file init486.c.

void HAL_TIM_Base_MspInit ( TIM_HandleTypeDef *  htim)

Definition at line 635 of file init486.c.

static void init_adc ( uint16_t  fs,
enum Num_Channels_In  chanin 
)
static

Definition at line 674 of file init486.c.

static void init_dac ( uint16_t  fs,
enum Num_Channels_Out  chanout 
)
static

Definition at line 457 of file init486.c.

void SystemClock_Config_HSE ( void  )
static

Hummels Config to give 80 MHz SYSCLK, with PLL48M1CLK=48 MHz The system Clock is configured as follows : System Clock source = PLL (HSE) SYSCLK(Hz) = 80000000 HCLK(Hz) = 80000000 AHB Prescaler = 1 APB1 Prescaler = 1 APB2 Prescaler = 1 HSE Frequency(Hz) = 8000000 (8 MHz external reference expected) PLL_M = 1 PLL_N = 20 PLL_R = 2 ( SYSCLK = PLLCLK = (8MHz)*N/M/R = 80 MHz ) PLL_P = 7 (No reason for this...) PLL_Q = 5 ( PLL48M1CLK = (16MHz)(N/M/Q) = 32 MHz !?! ) Flash Latency(WS) = 4.

HSE: Driven by 8 MHz ref clock (Requires jumper changes on STM32L476G-Discovery) MSI: Not configured here HSI: 16 MHz (Fixed frequency high speed internal Oscillator) LSI: 32.768 kHz (Low freq internal oscillator) ( PLL Input = HSE*N/M = 160 MHz ) SYSCLK: 80 MHz (= 160/R) HCLK (AHB Bus, Core, Memory, and DMA): 80 MHz (Max value) PCLK1 (APB1 Periferals, some USARTs and Timers): 80 MHz (Max value) PCLK2 (APB2 Periferals, some USARTs and Timers): 80 MHz (Max value)

Return values
None

Definition at line 293 of file init486.c.

void SystemClock_Config_MSI ( void  )
static

System Clock Configuration.

Hummels Config to give 80 MHz SYSCLK, with PLL48M1CLK=48 MHz The system Clock is configured as follows : System Clock source = PLL (MSI) SYSCLK(Hz) = 80000000 HCLK(Hz) = 80000000 AHB Prescaler = 1 APB1 Prescaler = 1 APB2 Prescaler = 1 MSI Frequency(Hz) = 16000000 (MSI Range=8) PLL_M = 2 PLL_N = 20 PLL_R = 2 ( SYSCLK = PLLCLK = (16MHz)*N/M/R = 80 MHz ) PLL_P = 7 (No reason for this...) PLL_Q = 5 ( PLL48M1CLK = (16MHz)(N/M/Q) = 32 MHz ?! ) Flash Latency(WS) = 4

HSE: Not assumed active (xtal not populated on STM32L476G-Discovery) MSI: 16 MHz (multiple speed internal RC Oscillator, configured using Range=8) HSI: 16 MHz (Fixed frequency high speed internal Oscillator) LSI: 32.768 kHz (Low freq internal oscillator) ( MSI *N/M = 160 MHz ) SYSCLK: 80 MHz (= 160/R) HCLK (AHB Bus, Core, Memory, and DMA): 80 MHz (Max value) PCLK1 (APB1 Periferals, some USARTs and Timers): 80 MHz (Max value) PCLK2 (APB2 Periferals, some USARTs and Timers): 80 MHz (Max value)

(ALTERNATIVE??? Use the HSI as the reference oscillator. Change N to 15.)

Parameters
None
Return values
None

Definition at line 226 of file init486.c.

void SysTick_Handler ( void  )

Definition at line 905 of file init486.c.

static void TIM4_Config ( uint16_t  fs)
static

Definition at line 755 of file init486.c.

void TIM6_DAC_IRQHandler ( void  )

Definition at line 877 of file init486.c.

Variable Documentation

float Actual_Sampling_Frequency
static

Definition at line 79 of file init486.c.

ADC_HandleTypeDef AdcHandle
static

Definition at line 72 of file init486.c.

ADC_HandleTypeDef AdcHandle2
static

Definition at line 73 of file init486.c.

DAC_HandleTypeDef DacHandle
static

Definition at line 71 of file init486.c.

enum Num_Channels_In Input_Configuration

Definition at line 88 of file init486.c.

JOYState_TypeDef JoyState = JOY_NONE

Definition at line 84 of file init486.c.

__IO FlagStatus KeyPressed = RESET

Definition at line 85 of file init486.c.

enum Num_Channels_Out Output_Configuration

Definition at line 87 of file init486.c.