snickerdoodle Platform Controller
firmware for STM32F0 platform controller
Main

Main program entry point and system clock configuration. More...

Functions

void SystemClock_Config (void)
 System Clock Configuration Configure and initialize the main, systick, timer and peripheral clocks.
 
int main (void)
 Main Program Entry Point Initializes each peripheral along with any interrupts and begins execution of the user application. More...
 

Detailed Description

Main program entry point and system clock configuration.

Function Documentation

◆ main()

int main ( void  )

#include <Src/main.c>

Main Program Entry Point Initializes each peripheral along with any interrupts and begins execution of the user application.

Reset of all peripherals, Initializes the Flash interface and the Systick timer.

Todo:
Check the main power supplies here before attempting to boot the Zynq
95 {
96  enum sd_zynq_boot boot;
97 
102  HAL_Init();
103 
104  /* Configure the system clock */
106 
107  /* Initialize the GPIO interface */
108  sd_gpio_init();
109 
110  /* Set all of the LEDs on */
111  HAL_GPIO_WritePin(RED_GPIO_Port, RED_Pin, GPIO_PIN_RESET);
112  HAL_GPIO_WritePin(WHITE_GPIO_Port, WHITE_Pin, GPIO_PIN_RESET);
113  HAL_GPIO_WritePin(GREEN_GPIO_Port, GREEN_Pin, GPIO_PIN_RESET);
114  HAL_GPIO_WritePin(BLUE_GPIO_Port, BLUE_Pin, GPIO_PIN_RESET);
115  HAL_GPIO_WritePin(ORANGE_GPIO_Port, ORANGE_Pin, GPIO_PIN_RESET);
116 
117  /* Check the boot configuration */
118  boot = sd_boot_select();
119 
120  /* Initialize all configured peripherals */
121  sd_adc_init();
122 
123  sd_i2c1_init();
124  sd_i2c2_init();
125 
126  sd_spi2_init();
127 
128  sd_tim1_init();
129  sd_tim3_init();
130 
131  sd_tim7_init();
132 
133  sd_usart1_init();
134  sd_usart2_init();
135 
136  sd_zynq_boot_config(boot);
137 
138  /* Initialize the UART buffers */
140 
141  /* Set the UART devices with the buffers and prepare to receive */
144 
145  /* Initialize the USB device */
146  MX_USB_DEVICE_Init();
147 
148  /* Initialize buttons and handlers */
150  RESET_BUTTON_GPIO_Port,
151  RESET_BUTTON_Pin,
152  20,
154  2000,
156 
157  /* Configure the antenna */
159 
160  /* Enable wireless clock */
161  sd_wl_clk_enable(TRUE);
162 
163  sd_bt_enable(TRUE);
164 
165  /* Enable I2C switch */
166  HAL_GPIO_WritePin(SMB_NRESET_GPIO_Port,
167  SMB_NRESET_Pin, GPIO_PIN_SET);
168 
169  /* Start USB, button and LED update timer interrupt */
170  HAL_TIM_Base_Start_IT(&htim7);
171 
172  /* Enable Zynq JTAG */
173  sd_zynq_jtag_enable(TRUE);
174 
179 
180  /* Short delay */
181  HAL_Delay(20);
182 
183  /* Enable Zynq power */
184  sd_zynq_enable();
185 
186  /* Poll until power good signal is asserted */
187  while (HAL_GPIO_ReadPin(ZYNQ_POWER_GOOD_GPIO_Port,
188  ZYNQ_POWER_GOOD_Pin) != GPIO_PIN_SET)
189  HAL_Delay(10);
190 
191  /* Enable Zynq clock */
192  sd_zynq_clk_enable(TRUE);
193 
194  /* Infinite loop */
195  while (1) {
196  HAL_Delay(250);
197  }
198 }
void sd_wl_clk_enable(uint8_t enable)
Wireless Clock Enable Enable the wireless module 32kHz clock source.
Definition: sd_platform.c:143
void sd_tim3_init(void)
Timer 3 Initialization.
Definition: sd_pwm.c:153
void sd_adc_init(void)
Definition: sd_adc.c:129
void sd_tim1_init(void)
Timer 1 Initialization.
Definition: sd_pwm.c:120
enum sd_buff_err sd_char_buff_init(struct sd_cbuf *buff, uint32_t size, uint8_t *pbuff)
Initialize Character Buffer.
Definition: sd_buffer.c:72
TIM_HandleTypeDef htim7
Definition: sd_tim.c:67
void sd_zynq_boot_config(enum sd_zynq_boot boot)
Zynq Boot Config Outputs boot select pins to zynq for desired boot media source.
Definition: sd_platform.c:177
void sd_bt_enable(uint8_t enable)
Bluetooth Enable Enable the Bluetooth interface on the wireless module.
Definition: sd_platform.c:159
enum sd_zynq_boot sd_boot_select(void)
Boot selection.
Definition: sd_platform.c:523
#define WL18xx_ANTENNA_SMA
Definition: sd_platform.h:68
sd_zynq_boot
Zynq boot pin enumeration.
Definition: sd_platform.h:153
struct sd_cbuf uart2_rx_cbuff
Definition: sd_platform.c:79
void sd_gpio_init(void)
GPIO Initialization Configure pins as analog, input, output, event_out and EXTI.
Definition: sd_gpio.c:68
struct sd_uart_dev uart1_dev
Definition: sd_uart.c:81
void sd_usart1_init(void)
USART 1 Initialization.
Definition: sd_uart.c:102
void sd_tim7_init(void)
Timer 7 Initialization.
Definition: sd_tim.c:82
void sd_i2c1_init(void)
I2C1 Initialization Initialize low-level hardware peripheral and set device handle.
Definition: sd_i2c.c:96
void sd_wl18xx_ant_config(uint8_t ant)
WL18xx Antenna Configuration Outputs antenna select pins for the wireless module. ...
Definition: sd_platform.c:312
void sd_zynq_jtag_enable(uint8_t enable)
Zynq JTAG Enable Enables the JTAG interface for programming the PS or PL.
Definition: sd_platform.c:127
#define CONS_UART_RX_BUFF_SIZE
Definition: sd_platform.h:61
enum sd_button_err sd_button_init(struct sd_button *butt, GPIO_TypeDef *port, uint16_t pin, uint32_t up_to, void(*up_cb)(void), uint32_t down_to, void(*down_cb)(void))
Initialize Button Port/Pin and State Machine.
Definition: sd_button.c:91
void sd_zynq_clk_enable(uint8_t enable)
Zynq Clock Enable Enables the main clock source for the Zynq APU.
Definition: sd_platform.c:110
void sd_zynq_enable(void)
Enable Zynq Power Enable the Zynq power rails by setting the enable pin high.
Definition: sd_platform.c:254
struct sd_cbuf uart1_rx_cbuff
Definition: sd_platform.c:78
void sd_zynq_disable(void)
Disable Zynq Power Disable the Zynq power rails by setting the enable pin low.
Definition: sd_platform.c:239
void SystemClock_Config(void)
System Clock Configuration Configure and initialize the main, systick, timer and peripheral clocks...
Definition: main.c:206
void sd_usart2_init(void)
USART 2 Initialization.
Definition: sd_uart.c:124
struct sd_button reset_button
Definition: sd_button.c:67
void sd_i2c2_init(void)
I2C2 Initialization Initialize low-level hardware peripheral and set device handle.
Definition: sd_i2c.c:123
uint8_t uart1_rx_buff[CONS_UART_RX_BUFF_SIZE]
Definition: sd_platform.c:83
uint8_t uart2_rx_buff[CONS_UART_RX_BUFF_SIZE]
Definition: sd_platform.c:84
enum sd_uart_err sd_uart_rx_init(struct sd_uart_dev *dev, struct sd_cbuf *rx_buff)
UART Receive Interrupt Initialization Enable and prepare the UART to receive on interrupt.
Definition: sd_uart.c:317