implement traffic lights?
This commit is contained in:
@@ -5,9 +5,40 @@
|
||||
* Author: ja
|
||||
*/
|
||||
|
||||
void breadboard(void)
|
||||
/*
|
||||
* #define RedLight_Pin GPIO_PIN_2
|
||||
* #define RedLight_GPIO_Port GPIOE
|
||||
*
|
||||
* #define YellowLight_Pin GPIO_PIN_3
|
||||
* #define YellowLight_GPIO_Port GPIOE
|
||||
*
|
||||
* #define GreenLight_Pin GPIO_PIN_4
|
||||
* #define GreenLight_GPIO_Port GPIOE
|
||||
*
|
||||
* RedLight: PE2
|
||||
* YellowLight: PE3
|
||||
* GreenLight: PE4
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include "breadboard.h"
|
||||
|
||||
// HAL_GPIO_WritePin(LED_EXT_GPIO_Port, LED_EXT_Pin, GPIO_PIN_RESET);
|
||||
void
|
||||
breadboard(int traffSPD)
|
||||
{
|
||||
// Traffic Light
|
||||
HAL_GPIO_WritePin(GreenLight_GPIO_Port, RedLight_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(RedLight_GPIO_Port, RedLight_Pin, GPIO_PIN_SET);
|
||||
HAL_Delay(traffSPD);
|
||||
|
||||
HAL_GPIO_WritePin(RedLight_GPIO_Port, YellowLight_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(YellowLight_GPIO_Port, YellowLight_Pin, GPIO_PIN_SET);
|
||||
HAL_Delay(traffSPD);
|
||||
|
||||
HAL_GPIO_WritePin(YellowLight_GPIO_Port, GreenLight_Pin, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GreenLight_GPIO_Port, GreenLight_Pin, GPIO_PIN_SET);
|
||||
HAL_Delay(traffSPD);
|
||||
|
||||
// Walk signal
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "breadboard.h"
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
@@ -144,15 +145,15 @@ int main(void)
|
||||
|
||||
/* Create the thread(s) */
|
||||
/* definition and creation of defaultTask */
|
||||
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 4096);
|
||||
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
|
||||
//osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 4096);
|
||||
//defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
|
||||
|
||||
/* USER CODE BEGIN RTOS_THREADS */
|
||||
/* add threads, ... */
|
||||
/* USER CODE END RTOS_THREADS */
|
||||
|
||||
/* Start scheduler */
|
||||
osKernelStart();
|
||||
//osKernelStart();
|
||||
|
||||
/* We should never get here as control is now taken by the scheduler */
|
||||
|
||||
@@ -160,6 +161,7 @@ int main(void)
|
||||
/* USER CODE BEGIN WHILE */
|
||||
while (1)
|
||||
{
|
||||
breadboard(333);
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
@@ -562,15 +564,18 @@ static void MX_GPIO_Init(void)
|
||||
/* USER CODE END MX_GPIO_Init_1 */
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOF_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOH_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOG_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOE, RedLight_Pin|YellowLight_Pin|GreenLight_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOC, NCS_MEMS_SPI_Pin|CSX_Pin|OTG_FS_PSO_Pin, GPIO_PIN_RESET);
|
||||
|
||||
@@ -583,6 +588,13 @@ static void MX_GPIO_Init(void)
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOG, LD3_Pin|LD4_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pins : RedLight_Pin YellowLight_Pin GreenLight_Pin */
|
||||
GPIO_InitStruct.Pin = RedLight_Pin|YellowLight_Pin|GreenLight_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : NCS_MEMS_SPI_Pin CSX_Pin OTG_FS_PSO_Pin */
|
||||
GPIO_InitStruct.Pin = NCS_MEMS_SPI_Pin|CSX_Pin|OTG_FS_PSO_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
|
||||
Reference in New Issue
Block a user