diff options
| author | Omar Magdy <omar.professional8777@gmail.com> | 2022-08-21 18:42:49 +0200 |
|---|---|---|
| committer | Omar Magdy <omar.professional8777@gmail.com> | 2022-08-21 18:42:49 +0200 |
| commit | 063ac23917f608202b337b09fe355d9223493245 (patch) | |
| tree | 8d45778269529e4d2a0bcbca8cc128c9a15cc0bd /main.c | |
| parent | ff6ccb57551afe8904254313fb7ed0204fe74d19 (diff) | |
| download | Traffic-light-063ac23917f608202b337b09fe355d9223493245.tar.xz Traffic-light-063ac23917f608202b337b09fe355d9223493245.zip | |
Added intital project
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 46 |
1 files changed, 46 insertions, 0 deletions
@@ -0,0 +1,46 @@ +#include "color.h"
+#include "systick.h"
+#include "stdio.h"
+
+int cnt = 0;
+
+void portFInit() {
+ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
+ while(!SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOF)) {};
+ GPIOUnlockPin(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4);
+ GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4);
+ GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
+ GPIOPadConfigSet (GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4,
+ GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPU);
+}
+
+void toggle_white() {
+ if((GPIO_PORTF_DATA_R & 0xe) == 0xe) {
+ reset_color();
+ } else {
+ set_color(WHITE);
+ }
+}
+
+void SysTick_Handler() {
+ cnt++;
+ if(cnt % 5 == 0) {
+ toggle_color(WHITE);
+ }
+}
+
+void toggle_interrupts() {
+ portFInit();
+ SysTickDisable();
+ SysTickPeriodSet(PERIOD);
+ SysTickIntEnable();
+ SysTickEnable();
+ while(1) {
+
+ }
+}
+
+int main()
+{
+ toggle_interrupts();
+}
|
