aio.c: cosmetic fix on file
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -33,10 +33,12 @@
|
|||||||
|
|
||||||
static int raw_bits;
|
static int raw_bits;
|
||||||
|
|
||||||
static mraa_result_t aio_get_valid_fp(mraa_aio_context dev)
|
static mraa_result_t
|
||||||
|
aio_get_valid_fp(mraa_aio_context dev)
|
||||||
{
|
{
|
||||||
if (advance_func->aio_get_valid_fp != NULL)
|
if (advance_func->aio_get_valid_fp != NULL)
|
||||||
return advance_func->aio_get_valid_fp(dev);
|
return advance_func->aio_get_valid_fp(dev);
|
||||||
|
|
||||||
char file_path[64]= "";
|
char file_path[64]= "";
|
||||||
|
|
||||||
//Open file Analog device input channel raw voltage file for reading.
|
//Open file Analog device input channel raw voltage file for reading.
|
||||||
@@ -46,20 +48,15 @@ static mraa_result_t aio_get_valid_fp(mraa_aio_context dev)
|
|||||||
dev->adc_in_fp = open(file_path, O_RDONLY);
|
dev->adc_in_fp = open(file_path, O_RDONLY);
|
||||||
if (dev->adc_in_fp == -1) {
|
if (dev->adc_in_fp == -1) {
|
||||||
fprintf(stderr, "Failed to open Analog input raw file %s for "
|
fprintf(stderr, "Failed to open Analog input raw file %s for "
|
||||||
"reading!\n", file_path); return( MRAA_ERROR_INVALID_RESOURCE);
|
"reading!\n", file_path);
|
||||||
|
return MRAA_ERROR_INVALID_RESOURCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return MRAA_SUCCESS;
|
return MRAA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialise an Analog input, connected to the specified channel
|
mraa_aio_context
|
||||||
*
|
mraa_aio_init(unsigned int aio_channel)
|
||||||
* @param aio_channel Analog input channel to read
|
|
||||||
*
|
|
||||||
* @returns pointer to mraa_aio_context structure after initialisation of
|
|
||||||
* Analog input pin connected to the device successfully, else returns NULL.
|
|
||||||
*/
|
|
||||||
mraa_aio_context mraa_aio_init(unsigned int aio_channel)
|
|
||||||
{
|
{
|
||||||
if (advance_func->aio_init_pre != NULL) {
|
if (advance_func->aio_init_pre != NULL) {
|
||||||
mraa_result_t pre_ret = (advance_func->aio_init_pre(aio_channel));
|
mraa_result_t pre_ret = (advance_func->aio_init_pre(aio_channel));
|
||||||
@@ -81,7 +78,8 @@ mraa_aio_context mraa_aio_init(unsigned int aio_channel)
|
|||||||
case -3:
|
case -3:
|
||||||
fprintf(stderr, "Platform not initialised");
|
fprintf(stderr, "Platform not initialised");
|
||||||
return NULL;
|
return NULL;
|
||||||
default: return NULL;
|
default:
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,17 +107,12 @@ mraa_aio_context mraa_aio_init(unsigned int aio_channel)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Read the input voltage.
|
unsigned int
|
||||||
*
|
mraa_aio_read(mraa_aio_context dev)
|
||||||
* @param pointer to mraa_aio_context structure initialised by
|
|
||||||
* mraa_aio_init()
|
|
||||||
*
|
|
||||||
* @returns The current input voltage. By default, a 10bit value
|
|
||||||
*/
|
|
||||||
unsigned int mraa_aio_read(mraa_aio_context dev)
|
|
||||||
{
|
{
|
||||||
char buffer[16];
|
char buffer[16];
|
||||||
unsigned int shifter_value = 0;
|
unsigned int shifter_value = 0;
|
||||||
@@ -158,13 +151,8 @@ unsigned int mraa_aio_read(mraa_aio_context dev)
|
|||||||
return analog_value;
|
return analog_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Close the analog input and free context memory
|
mraa_result_t
|
||||||
*
|
mraa_aio_close(mraa_aio_context dev)
|
||||||
* @param dev - the analog input context
|
|
||||||
*
|
|
||||||
* @return mraa result type.
|
|
||||||
*/
|
|
||||||
mraa_result_t mraa_aio_close(mraa_aio_context dev)
|
|
||||||
{
|
{
|
||||||
if (NULL != dev)
|
if (NULL != dev)
|
||||||
free(dev);
|
free(dev);
|
||||||
@@ -172,14 +160,8 @@ mraa_result_t mraa_aio_close(mraa_aio_context dev)
|
|||||||
return(MRAA_SUCCESS);
|
return(MRAA_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set the bits value from read.
|
mraa_result_t
|
||||||
*
|
mraa_aio_set_bit(mraa_aio_context dev, int bits)
|
||||||
* @param dev the analog input context
|
|
||||||
* @param bits the bits the return from read should be i.e 10
|
|
||||||
*
|
|
||||||
* @return mraa result type
|
|
||||||
*/
|
|
||||||
mraa_result_t mraa_aio_set_bit(mraa_aio_context dev, int bits)
|
|
||||||
{
|
{
|
||||||
if (dev == NULL) {
|
if (dev == NULL) {
|
||||||
fprintf(stderr, "AIO Device not valid\n");
|
fprintf(stderr, "AIO Device not valid\n");
|
||||||
@@ -187,20 +169,14 @@ mraa_result_t mraa_aio_set_bit(mraa_aio_context dev, int bits)
|
|||||||
}
|
}
|
||||||
if (bits < 1) {
|
if (bits < 1) {
|
||||||
fprintf(stderr, "AIO Device not valid\n");
|
fprintf(stderr, "AIO Device not valid\n");
|
||||||
// Error Message Here. find with grep fprintf
|
|
||||||
return MRAA_ERROR_INVALID_PARAMETER;
|
return MRAA_ERROR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
dev->value_bit = bits;
|
dev->value_bit = bits;
|
||||||
return MRAA_SUCCESS;
|
return MRAA_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
int
|
||||||
* Gets the bit value mraa is shifting the analog read to.
|
mraa_aio_get_bit(mraa_aio_context dev)
|
||||||
* @param dev the analog input context
|
|
||||||
*
|
|
||||||
* @return bit value mraa is set return from the read function
|
|
||||||
*/
|
|
||||||
int mraa_aio_get_bit(mraa_aio_context dev)
|
|
||||||
{
|
{
|
||||||
if (dev == NULL) {
|
if (dev == NULL) {
|
||||||
fprintf(stderr, "AIO Device not valid\n");
|
fprintf(stderr, "AIO Device not valid\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user