BBBAndroidHAL  V1.0
 All Classes Files Functions Variables Macros
bbbandroidHAL.h
Go to the documentation of this file.
1 /**********************************************************
2  Main bbbandroidHAL header file
3 
4  Written by Andrew Henderson (hendersa@icculus.org)
5  Modified by Ankur Yadav (ankurayadav@gmail.com)
6 
7  This code is made available under the BSD license.
8 **********************************************************/
9 
16 #include <stdio.h>
17 
18 #ifndef __BBBANDROIDHAL_H__
19 #define __BBBANDROIDHAL_H__
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
24 
25 /* Library init/shutdown */
26 extern int openBBBAndroidHAL(void);
27 extern int closeBBBAndroidHAL(void);
28 
29 /* GPIO interfacing functions */
30 extern int openGPIO(const int useMmap);
31 extern int readGPIO(const unsigned int header, const unsigned int pin);
32 extern int writeGPIO(const unsigned int header, const unsigned int pin,
33 const unsigned int value);
34 extern void closeGPIO(void);
35 
36 /* PWM interfacing functions */
37 extern int pwmSetPeriod(const uint8_t channel, const uint32_t period_ns);
38 extern int pwmGetPeriod(const uint8_t channel);
39 extern int pwmSetDutyCycle(const uint8_t channel, const uint32_t duration_ns);
40 extern int pwmGetDutyCycle(const uint8_t channel);
41 extern int pwmSetPolarity(const uint8_t channel, const uint8_t polarity);
42 extern int pwmGetPolarity(const uint8_t channel);
43 extern int pwmRun(const uint8_t channel);
44 extern int pwmStop(const uint8_t channel);
45 extern int pwmRunCheck(const uint8_t channel);
46 
47 /* ADC interfacing functions */
48 extern int readADC(const uint8_t channel);
49 
50 /* I2C interfacing functions */
51 extern int i2cOpenAdaptor(const uint8_t adaptorNumber);
52 extern int i2cSetSlave(const int i2cFD, const uint8_t address);
53 extern void i2cClose(const int i2cFD);
54 extern int i2cSetAddress(const int i2cFD, const uint8_t add);
55 extern int i2cWriteByte(const int i2cFD, const uint8_t add, const uint8_t byte);
56 extern int i2cWriteBytes(const int i2cFD, const uint8_t add, const int length, const uint8_t *bytes);
57 extern int i2cReadByte(const int i2cFD, const uint8_t add);
58 extern int i2cReadBytes(const int i2cFD, const uint8_t add, const int length, uint8_t *buff);
59 
60 /* SPI interfacing functions */
61 extern int spiTransfer(const int spiFD, const uint8_t tx[], const uint8_t rx[], const int len);
62 extern int spiOpen(const uint8_t bus, const uint8_t device, const uint32_t speed, const uint8_t mode, const uint8_t bpw);
63 extern int spiReadByte(const int spiFD, const uint8_t regAdd);
64 extern unsigned char* spiReadBytes(const int spiFD, const int len, const uint8_t startAdd);
65 extern int spiWriteRegByte(const int spiFD, const uint8_t regAdd, const uint8_t data);
66 extern int spiWriteBytes(const int spiFD, const uint8_t data[], const int len);
67 extern int spiSetMode(const int spiFD, const uint8_t mode);
68 extern int spiSetSpeed(const int spiFD, const uint32_t speed);
69 extern int spiSetBitsPerWord(const int spiFD, const uint8_t bpw);
70 extern void spiClose(const int spiFD);
71 
72 /* CAN interfacing functions */
73 extern int canOpenSocket(const int socket_type, const int protocol);
74 extern int canOpenRaw(const char *port);
75 extern unsigned char* canReadBytes(const int fd, int *length);
76 extern int canSendBytes(const int canFD, const int no_bytes, const uint8_t data[]);
77 extern void canClose(const int canFD);
78 
79 /* UART interfacing functions */
80 extern int uartOpen(const uint8_t device, const uint32_t bdrate);
81 extern int uartWrite(const int uartFD, const int length, const uint8_t *bytes);
82 extern int uartRead(const int uartFD, const int length, uint8_t *bytes);
83 extern void uartClose(const int uartFD);
84 
85 /* USB interfacing functions */
86 extern ssize_t usbInit();
87 extern void usbClose();
88 extern int usbGetDevices(int ids[][8], unsigned char strings[][3][256]);
89 
90 #ifdef __cplusplus
91 }
92 #endif /* __cplusplus */
93 #endif /* __BBBANDROIDHAL_H__ */
int uartRead(const int uartFD, const int length, uint8_t *bytes)
Definition: uart.c:146
int writeGPIO(const unsigned int header, const unsigned int pin, const unsigned int value)
Definition: gpio.c:361
int pwmSetDutyCycle(const uint8_t channel, const uint32_t duration_ns)
Definition: pwm.c:84
int spiSetBitsPerWord(const int spiFD, const uint8_t bpw)
Definition: spi.c:195
int pwmStop(const uint8_t channel)
Definition: pwm.c:217
int i2cWriteByte(const int i2cFD, const uint8_t add, const uint8_t byte)
Definition: i2c.c:90
int pwmRunCheck(const uint8_t channel)
Definition: pwm.c:243
int readADC(const uint8_t channel)
Definition: adc.c:30
void i2cClose(const int i2cFD)
Definition: i2c.c:178
int i2cSetSlave(const int i2cFD, const uint8_t address)
Definition: i2c.c:53
int pwmGetPolarity(const uint8_t channel)
Definition: pwm.c:164
int canOpenRaw(const char *port)
Definition: can.c:61
int pwmSetPolarity(const uint8_t channel, const uint8_t polarity)
Definition: pwm.c:138
void spiClose(const int spiFD)
Definition: spi.c:246
int pwmRun(const uint8_t channel)
Definition: pwm.c:191
ssize_t usbInit()
Definition: usb.c:30
int canOpenSocket(const int socket_type, const int protocol)
Definition: can.c:40
unsigned char * canReadBytes(const int fd, int *length)
Definition: can.c:93
void canClose(const int canFD)
Definition: can.c:165
int pwmGetDutyCycle(const uint8_t channel)
Definition: pwm.c:110
int i2cReadBytes(const int i2cFD, const uint8_t add, const int length, uint8_t *buff)
Definition: i2c.c:160
void closeGPIO(void)
Definition: gpio.c:396
int i2cOpenAdaptor(const uint8_t adaptorNumber)
Definition: i2c.c:29
int spiSetSpeed(const int spiFD, const uint32_t speed)
Definition: spi.c:172
int usbGetDevices(int ids[][8], unsigned char strings[][3][256])
Definition: usb.c:57
int i2cWriteBytes(const int i2cFD, const uint8_t add, const int length, const uint8_t *bytes)
Definition: i2c.c:115
int spiOpen(const uint8_t bus, const uint8_t device, const uint32_t speed, const uint8_t mode, const uint8_t bpw)
Definition: spi.c:221
int pwmSetPeriod(const uint8_t channel, const uint32_t period_ns)
Definition: pwm.c:30
void usbClose()
Definition: usb.c:162
unsigned char * spiReadBytes(const int spiFD, const int len, const uint8_t startAdd)
Definition: spi.c:88
int uartOpen(const uint8_t device, const uint32_t bdrate)
Definition: uart.c:78
int i2cSetAddress(const int i2cFD, const uint8_t add)
Definition: i2c.c:71
int spiWriteRegByte(const int spiFD, const uint8_t regAdd, const uint8_t data)
Definition: spi.c:111
int readGPIO(const unsigned int header, const unsigned int pin)
Definition: gpio.c:320
void uartClose(const int uartFD)
Definition: uart.c:161
int canSendBytes(const int canFD, const int no_bytes, const uint8_t data[])
Definition: can.c:139
int spiReadByte(const int spiFD, const uint8_t regAdd)
Definition: spi.c:65
int spiWriteBytes(const int spiFD, const uint8_t data[], const int len)
Definition: spi.c:132
int openGPIO(const int useMmap)
Definition: gpio.c:169
int pwmGetPeriod(const uint8_t channel)
Definition: pwm.c:56
int spiSetMode(const int spiFD, const uint8_t mode)
Definition: spi.c:149
int uartWrite(const int uartFD, const int length, const uint8_t *bytes)
Definition: uart.c:127
int spiTransfer(const int spiFD, const uint8_t tx[], const uint8_t rx[], const int len)
Definition: spi.c:39
int i2cReadByte(const int i2cFD, const uint8_t add)
Definition: i2c.c:135