Sensorian  1.0
C API Reference Guide Library
Utilities.c
Go to the documentation of this file.
1 #include "Utilities.h"
2 
6 
12 void delay_ms(unsigned int ms)
13 {
14  bcm2835_delay(ms);
15 }
16 
22 void pinModeOutput(PIN_t pin)
23 {
24  bcm2835_gpio_fsel(pin, BCM2835_GPIO_FSEL_OUTP);
25 }
26 
33 void digitalWrite(PIN_t pin, unsigned char level)
34 {
35  bcm2835_gpio_write(pin, level); // set to level
36 }
37 
44 {
45  bcm2835_gpio_fsel(pin,BCM2835_GPIO_FSEL_INPT); // Set the pin to be an input
46  bcm2835_gpio_set_pud(pin, BCM2835_GPIO_PUD_DOWN); // Enable pull up.
47  PinLevel_t pinLevel = (PinLevel_t)bcm2835_gpio_lev(pin); //read voltage level on MFP pin
48  return pinLevel;
49 }
50 
57 {
58  bcm2835_gpio_ren(pin); //enable rising edge detect on pin
59 }
60 
67 {
68  bcm2835_gpio_clr_ren(pin); //Disable rising edge detect on pin
69 }
70 
77 {
78  bcm2835_gpio_ren(pin); //enable rising edge detect on pin
79 }
80 
87 {
88  bcm2835_gpio_clr_ren(pin); //Disable rising edge detect on pin
89 }
90 
97 {
98  bcm2835_gpio_ren(pin); //enable rising edge detect on pin
99 }
100 
107 {
108  bcm2835_gpio_clr_ren(pin); //Disable rising edge detect on pin
109 }
110 
116 void EnableDetectLowLevel(PIN_t pin)
117 {
118  bcm2835_gpio_ren(pin); //enable rising edge detect on pin
119 }
120 
127 {
128  bcm2835_gpio_clr_ren(pin); //Disable rising edge detect on pin
129 }
130 
137 {
138  bcm2835_gpio_aren(pin); //enable rising edge detect on pin
139 }
140 
147 {
148  bcm2835_gpio_clr_aren(pin); //Disable rising edge detect on pin
149 }
150 
156 unsigned char CheckPinforEvent(PIN_t pin)
157 {
158  unsigned char event = bcm2835_gpio_eds(pin); //Check for event detection
159  bcm2835_gpio_set_eds(pin); //Clear even detection interrupt flags
160  return event;
161 }
162 
void pinModeOutput(PIN_t pin)
Configures the given pin as output.
Definition: Utilities.c:49
void DisableDetectRisingEdge(PIN_t pin)
Disables detection of rising edge.
Definition: Utilities.c:93
void EnableDetectFallingEdge(PIN_t pin)
Enables detection of falling edge.
Definition: Utilities.c:103
void DisableDetectFallinggEdge(PIN_t pin)
Dsiables detection of falling edge.
Definition: Utilities.c:113
void DisableDetectRisingInterrupt(PIN_t pin)
Disables detection of rising edge interrupt.
Definition: Utilities.c:173
void EnableDetectRisingEdge(PIN_t pin)
Enables detection of rising edge.
Definition: Utilities.c:83
unsigned char CheckPinforEvent(PIN_t pin)
Checks fro even on given pin.
Definition: Utilities.c:183
PinLevel_t ReadPinStatus(PIN_t pin)
Configures the pins as input and returns the pin status.
Definition: Utilities.c:70
void EnableDetectLowLevel(PIN_t pin)
Enables detection of low level.
Definition: Utilities.c:143
enum PinLev PinLevel_t
void DisableDetectHighLevel(PIN_t pin)
Disables detection of high level.
Definition: Utilities.c:133
uint8_t PIN_t
Definition: Utilities.h:37
void delay_ms(unsigned int ms)
Delay in ms.
Definition: Utilities.c:39
void digitalWrite(PIN_t pin, unsigned char level)
Write a logic level to the pin. The pin should be confgured as output.
Definition: Utilities.c:60
void EnableDetectHighLevel(PIN_t pin)
Enables detection of high level on pin.
Definition: Utilities.c:123
void DisableDetectLowLevel(PIN_t pin)
Disables detection of low level.
Definition: Utilities.c:153
void EnableDetectRisingInterrupt(PIN_t pin)
Enables detection of rising edge interrupt.
Definition: Utilities.c:163