-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
103 lines (86 loc) · 4.02 KB
/
main.c
File metadata and controls
103 lines (86 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* FreeRTOS Kernel V10.3.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* http://www.FreeRTOS.org
* http://aws.amazon.com/freertos
*
* 1 tab == 4 spaces!
*/
/* Kernel includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "semphr.h"
/* Project includes. */
#include "system_stm32f4xx.h"
#include "leds.h"
#include "pattern.h"
#include "audio.h"
#include "stm32f4xx_rcc.h"
/* Hardware and starter kit includes. */
#include "arm_comm.h"
#include "stm32f4_discovery.h"
#include "stm32f4xx.h"
#include "stm32f4xx_conf.h"
/* Priorities for the demo application tasks (higher numbers preempt lower numbers) */
#define mainUPDATE_LEDS_PRIORITY ( tskIDLE_PRIORITY + 2UL )
#define mainCREATE_PATTERN_PRIORITY ( tskIDLE_PRIORITY + 1UL )
/* Task stack sizes. */
#define configUPDATE_LEDS_STACK_SIZE (configMINIMAL_STACK_SIZE * 10)
#define configCREATE_PATTERN_STACK_SIZE (configMINIMAL_STACK_SIZE * 40)
/* Task Handles. */
extern TaskHandle_t xUpdateLedsHandle;
extern TaskHandle_t xCreatePatternHandle;
/*-----------------------------------------------------------*/
int main(void)
{
/* Remove the secret clock doubler.... */
RCC->CFGR &= ~RCC_CFGR_PPRE1;
RCC->CFGR &= ~RCC_CFGR_PPRE2;
RCC->CFGR |= RCC_CFGR_PPRE1_DIV8;
RCC->CFGR |= RCC_CFGR_PPRE2_DIV4;
/* Update the MCU and peripheral clock frequencies */
SystemCoreClockUpdate();
/* Initialize all four LEDs built into the starter kit */
STM_EVAL_LEDInit( LED3 ); // Update LEDs stack overflow (ORG)
STM_EVAL_LEDInit( LED4 ); // Create Pattern stack overflow (GRN)
STM_EVAL_LEDInit( LED5 ); // Sample timer complete before ADC conversion (RED)
STM_EVAL_LEDInit( LED6 );
/* Initialize the debug timer. */
vInitDebug();
/* Initialize the individually addressable LEDs. */
vInitLeds();
/* Initialize the ADC/DMA/DSP instructions. */
vInitAudio();
/* Spawn the tasks. */
/* Task, Task Name, Stack Size, parameters, priority, task handle */
xTaskCreate( vUpdateLedStrip, "UpdateLeds", configUPDATE_LEDS_STACK_SIZE, NULL, mainUPDATE_LEDS_PRIORITY, &xUpdateLedsHandle );
xTaskCreate( vCreatePattern, "CreatePattern", configCREATE_PATTERN_STACK_SIZE, NULL, mainCREATE_PATTERN_PRIORITY, &xCreatePatternHandle );
/* Start the scheduler. */
vTaskStartScheduler();
/* If all is well, the scheduler will now be running, and the following line
will never be reached. If the following line does execute, then there was
insufficient FreeRTOS heap memory available for the idle and/or timer tasks
to be created. See the memory management section on the FreeRTOS web site
for more details. */
while ( 1 );
}
/*-----------------------------------------------------------*/