diff options
author | siddhu8990 | 2016-02-01 11:05:35 +0530 |
---|---|---|
committer | siddhu8990 | 2016-02-01 11:05:35 +0530 |
commit | 3425c4fedbdbc7e1a3440df7502d9af93f466b84 (patch) | |
tree | 55f138b2e4c2133b1d01ce4959996452213e2d18 /2.3-1/src/c/hardware/rasberrypi | |
parent | ef666a6b9ac74d5effe8b34179cc3ad0c247e7c3 (diff) | |
download | Scilab2C-3425c4fedbdbc7e1a3440df7502d9af93f466b84.tar.gz Scilab2C-3425c4fedbdbc7e1a3440df7502d9af93f466b84.tar.bz2 Scilab2C-3425c4fedbdbc7e1a3440df7502d9af93f466b84.zip |
Support for RPi gpios added
Diffstat (limited to '2.3-1/src/c/hardware/rasberrypi')
14 files changed, 249 insertions, 0 deletions
diff --git a/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c b/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c new file mode 100644 index 00000000..6f065586 --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalIns.c @@ -0,0 +1,30 @@ +// Function to read the state of the gpio pin +// +// Calling Sequence +// u8RPI_DigitalIn(pin) +// +// Parameters +// pin : pin of RPi to be read +// +// Returns +// state: Current state of the specified gpio pin +// +// Description +// There are few pins available on RPi as Gpio or digital i/o. These pins can be used as digital output or input. Using this function, current state (low/high) of any gpio pin can be read. 'pin' name must be provided from list provided. Please refer '' for complete list of pins. 'state' can be 0 or 1 depending upon state of the pin (Low/High). RPI_DigitalSetup with appropriate arguments must be called before using this function. +// Examples +// u8RPI_DigitalIn(RPI_GPIO_P1_03,1) //Returns the state of pin 3 of header P1 +// +// +// Authors +// Siddhesh Wani +// + +#include "types.h" +#include "RPIPeripheralDigital.h" + +uint8 u8RPIDigitalIns(uint8 pin) +{ + uint8 state = 0; + state = bcm2835_gpio_lev(pin); + return (state); +} diff --git a/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c b/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c new file mode 100644 index 00000000..375ca891 --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalOuts.c @@ -0,0 +1,30 @@ +// Function to change the output state of the gpio pin +// +// Calling Sequence +// u8RPI_DigitalOuts(pin,state) +// +// Parameters +// pin : pin of RPi to be used +// state : desired output state for pin (0 -> LOW, 1 -> HIGH) +// +// Description +// There are few pins available on RPi as Gpio or digital i/o. These pins can be used as digital output or input. 'Pin' name must be provided from list provided. Please refer '' for complete list of pins. 'state' can be 0 or 1 depending upon desired output (Low/High). RPI_DigitalSetup with appropriate arguments must be called before using this function. +// Examples +// u8RPI_DigitalOuts(RPI_GPIO_P1_03,1) //Sets pin 3 of header P1 as 'high' output +// +// +// Authors +// Siddhesh Wani +// + +#include "types.h" +#include "RPIPeripheralDigital.h" + + +uint8 u8RPIDigitalOuts(uint8 pin, uint8 state) +{ + if (state == 0) //low output + bcm2835_gpio_clr(pin); + if (state == 1) //high output + bcm2835_gpio_set(pin); +} diff --git a/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c b/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c new file mode 100644 index 00000000..277c620f --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/gpio/u8RPIDigitalSetups.c @@ -0,0 +1,38 @@ +// Function to setup digital pins. +// +// Calling Sequence +// u8RPI_DigitalSetup(pin,direction) +// +// Parameters +// pin : pin of RPi to be used +// direction : direction to be set for pin (0 -> INPUT, 1 -> OUTPUT) +// +// Description +// There are few pins available on RPi as Gpio or digital io. These pins can be used as digital output or input. Pin name must be provided from list provided. Please refer '' for complete list of pins. Direction can be 0 or 1 depending upon desired function (Input/output) +// Examples +// RPI_DigitalSetup(RPI_GPIO_P1_03,0) //Sets pin 3 of header P1 as input +// +// See also +// RPI_DigitalIn RPI_DigitalOut +// +// +// Authors +// Siddhesh Wani +// + +// This is curretly dummy function. It provides no functionality but is required +// for providing support for generating C code for RPi. +#include "types.h" +#include "RPIPeripheralDigital.h" + +uint8 u8RPIDigitalSetups(uint8 pin, uint8 direction) +{ + if(direction == 1) //Pin to be used as output + { + bcm2835_gpio_fsel(pin, BCM2835_GPIO_FSEL_OUTP); + } + else + { + bcm2835_gpio_fsel(pin, BCM2835_GPIO_FSEL_INPT); + } +} diff --git a/2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralDigital.h b/2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralDigital.h new file mode 100644 index 00000000..575a8b43 --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralDigital.h @@ -0,0 +1,22 @@ +/* This file declares functions and constants related to GPIO pins*/ + +#ifndef __RPIPERIPHERALGPIO_H__ +#define __RPIPERIPHERALGPIO_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "types.h" +#include "bcm2835.h" + +uint8 u8RPIDigitalSetups(uint8 pin, uint8 direction); +uint8 u8RPIDigitalOuts(uint8 pin, uint8 state); +uint8 u8RPIDigitalIns(uint8 pin); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif //__RPIPERIPHERALGPIO_H__ diff --git a/2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralUtil.h b/2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralUtil.h new file mode 100644 index 00000000..809595f3 --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/includes/RPIPeripheralUtil.h @@ -0,0 +1,20 @@ +/* This file declares functions and constants related to rasberrypi*/ + +#ifndef __RPIPERIPHERALUTIL_H__ +#define __RPIPERIPHERALUTIL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "types.h" +#include "bcm2835.h" + +uint8 u16RPIDelayMillis(uint16 time); +uint8 u16RPIDelayMicros(uint16 time); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif //__RPIPERIPHERALUTIL_H__ diff --git a/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralDigital.h b/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralDigital.h new file mode 100644 index 00000000..022bed56 --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralDigital.h @@ -0,0 +1,27 @@ +//This file defines constants corresponding to gpios. +// +// Authors +// Siddhesh Wani +// + +#ifndef __INT_RPIPERIPHERALGPIO_H__ +#define __INT_RPIPERIPHERALGPIO_H__ + +#include "types.h" +#include "RPIPeripheralDigital.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define RPI_DigitalSetup(in1,in2) u8RPIDigitalSetups((uint8) in1, (uint8) in2); + +#define RPI_DigitalIn(in1,in2) u8RPIDigitalIns((uint8) in1); + +#define RPI_DigitalOut(in1,in2) u8RPIDigitalOuts((uint8) in1, (uint8) in2); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* !__RPIPERIPHERALGPIO_H__ */ diff --git a/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralUtil.h b/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralUtil.h new file mode 100644 index 00000000..92020f9a --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/interfaces/int_RPIPeripheralUtil.h @@ -0,0 +1,23 @@ +// +// Authors +// Siddhesh Wani +// + +#ifndef __INT_RPIPERIPHERALUTIL_H__ +#define __INT_RPIPERIPHERALUTIL_H__ + +#include "types.h" +#include "RPIPeripheralUtil.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define RPI_DelayMicro(in1) u16RPIDelayMicros((uint16) in1); +#define RPI_DelayMilli(in1) u16RPIDelayMillis((uint16) in1); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* !__RPIPERIPHERALUTIL_H__ */ diff --git a/2.3-1/src/c/hardware/rasberrypi/libraries/libbcm2835.a b/2.3-1/src/c/hardware/rasberrypi/libraries/libbcm2835.a Binary files differnew file mode 100644 index 00000000..bab5afcf --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/libraries/libbcm2835.a diff --git a/2.3-1/src/c/hardware/rasberrypi/libraries/libcblas.a b/2.3-1/src/c/hardware/rasberrypi/libraries/libcblas.a Binary files differnew file mode 100644 index 00000000..7a460be9 --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/libraries/libcblas.a diff --git a/2.3-1/src/c/hardware/rasberrypi/libraries/libgfortran.a b/2.3-1/src/c/hardware/rasberrypi/libraries/libgfortran.a Binary files differnew file mode 100644 index 00000000..7aacee8f --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/libraries/libgfortran.a diff --git a/2.3-1/src/c/hardware/rasberrypi/libraries/liblapack.a b/2.3-1/src/c/hardware/rasberrypi/libraries/liblapack.a Binary files differnew file mode 100644 index 00000000..726f2b99 --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/libraries/liblapack.a diff --git a/2.3-1/src/c/hardware/rasberrypi/libraries/librefblas.a b/2.3-1/src/c/hardware/rasberrypi/libraries/librefblas.a Binary files differnew file mode 100644 index 00000000..300a0db5 --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/libraries/librefblas.a diff --git a/2.3-1/src/c/hardware/rasberrypi/util/u16RPIDelayMicros.c b/2.3-1/src/c/hardware/rasberrypi/util/u16RPIDelayMicros.c new file mode 100644 index 00000000..e564d882 --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/util/u16RPIDelayMicros.c @@ -0,0 +1,29 @@ +// Function to insert some delay in code execution. +// +// Calling Sequence +// u16RPIDelayMicros(time) +// +// Parameters +// time: time(microseconds) for which execution is to be delayed +// +// Description +// this function can be used for insertig execution delays. 'time' should be +// specified in microseconds.'time' should be between (1-65536). +// Note: Delay inserted by this function is not accurate, but depedent on +// operating system, other running tasks etc. +// +// Examples +// u16RPIDelayMicros(100) //This will delay the execution of next code by 100 ms. +// +// +// Authors +// Siddhesh Wani +// +#include "types.h" +#include "RPIPeripheralUtil.h" + +uint8 u16RPIDelayMicros(uint16 time) +{ + bcm2835_delayMicroseconds(time); +} + diff --git a/2.3-1/src/c/hardware/rasberrypi/util/u16RPIDelayMillis.c b/2.3-1/src/c/hardware/rasberrypi/util/u16RPIDelayMillis.c new file mode 100644 index 00000000..bc2e6dd0 --- /dev/null +++ b/2.3-1/src/c/hardware/rasberrypi/util/u16RPIDelayMillis.c @@ -0,0 +1,30 @@ +// Function to insert some delay in code execution. +// +// Calling Sequence +// u16RPIDelayMillis(time) +// +// Parameters +// time: time(milliseconds) for which execution is to be delayed +// +// Description +// this function can be used for insertig execution delays. 'time' should be +// specified in milliseconds.'time' should be between (1-65536). +// Note: Delay inserted by this function is not accurate, but depedent on +// operating system, other running tasks etc. +// +// Examples +// u16RPIDelayMillis(100) //This will delay the execution of next code by 100 ms. +// +// +// Authors +// Siddhesh Wani +// +#include "types.h" +#include "RPIPeripheralUtil.h" + +uint8 u16RPIDelayMillis(uint16 time) +{ + bcm2835_delay(time); + +} + |