-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
>Added utils library and moved onboard led blink function to it
- Loading branch information
Abhijith Sriram
committed
Oct 13, 2024
1 parent
970bddf
commit df65558
Showing
13 changed files
with
97 additions
and
20 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,12 @@ | ||
cmake_minimum_required(VERSION 3.25.0) | ||
|
||
message("Building joystick") | ||
set(SOURCES joystick.c) | ||
set(HEADERS joystick.h) | ||
add_library(joystick joystick.c) | ||
set_target_properties(joystick PROPERTIES FOLDER "appls/joystick") | ||
target_include_directories(joystick PRIVATE | ||
${CMAKE_SOURCE_DIR}/src/lib/timer | ||
${CMAKE_SOURCE_DIR}/src/lib/eeprom | ||
${CMAKE_SOURCE_DIR}/src/lib/utils | ||
${CMAKE_SOURCE_DIR}/src/lib/pins) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,24 @@ | ||
#include "joystick.h" | ||
#include "timer.h" | ||
#include "pin.h" | ||
#include "utils.h" | ||
|
||
void joystick_setup() | ||
{ | ||
/* Configure pin PB5 to output to show sensor has detected something */ | ||
Configure_pinPort(PORTB, (uint8_t)PINB5, OUTPUT); | ||
/* Configure PD2 as the trigger for the sensor */ | ||
Configure_pinPort(PORTD, (uint8_t)PIND2, INPUT); | ||
} | ||
void joystick_main() | ||
{ | ||
if(Read_pin(PORTD, (uint8_t)PIND2) == PIN_LOW) | ||
{ | ||
/* The push button is high by default */ | ||
Blink_onboard_led(1000U); | ||
} | ||
else | ||
{ | ||
Write_pin(PORTB, (uint8_t)PINB5, PIN_LOW); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,7 @@ | ||
#ifndef __JOYSTICK__ | ||
#define __JOYSTICK__ | ||
|
||
void joystick_setup(); | ||
void joystick_main(); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,8 @@ | ||
cmake_minimum_required(VERSION 3.25.0) | ||
|
||
message("Building PINS") | ||
set(SOURCES utils.c) | ||
set(HEADERS utils.h) | ||
add_library(UTILS STATIC utils.c) | ||
set_target_properties(UTILS PROPERTIES FOLDER "lib/utils") | ||
target_include_directories(UTILS PRIVATE ${CMAKE_SOURCE_DIR}/src/lib/pins) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,21 @@ | ||
#include <stdint.h> | ||
#include "utils.h" | ||
#include "pin.h" | ||
|
||
/* | ||
* Function to blink the onboard LED. This function assumes that the pin PB5 | ||
* is set as output prior to the function call | ||
* | ||
* INPUT | ||
* @param None | ||
* | ||
* OUTPUT | ||
* @param None | ||
*/ | ||
void Blink_onboard_led(uint32_t delay_ms) | ||
{ | ||
Write_pin(PORTB, (uint8_t)PINB5, PIN_HIGH); | ||
Delay_ms(delay_ms); | ||
Write_pin(PORTB, (uint8_t)PINB5, PIN_LOW); | ||
Delay_ms(delay_ms); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,7 @@ | ||
#ifndef __UTILS__ | ||
#define __UTILS__ | ||
#include <stdint.h> | ||
|
||
void Blink_onboard_led(uint32_t delay_ms); | ||
|
||
#endif |