X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=server%2Fbbb_pin.c;h=bd31365cdecb61aa17768554531d680bfb6b4f19;hb=6bc90047ed36b392d90a1bf778baf9687b835f2d;hp=7248c5abe97786ea139eaa9a2b44f0cebc005a77;hpb=7206c183756185eeea99afec12f11506810a0a33;p=matches%2FMCTX3420.git diff --git a/server/bbb_pin.c b/server/bbb_pin.c index 7248c5a..bd31365 100644 --- a/server/bbb_pin.c +++ b/server/bbb_pin.c @@ -1,6 +1,7 @@ /** * @file bbb_pin.c - * @purpose Implementation of BBB pin control functions and structures + * @brief Implementation of BBB pin control functions and structures + * On non-beaglebone (actually non-arm) platforms, this code is disabled. * THIS CODE IS NOT THREADSAFE */ @@ -55,6 +56,32 @@ static PWM_Pin g_pwm[PWM_NUM_PINS] = {{0}}; static char g_buffer[BUFSIZ] = {0}; +/** + * Maps a GPIO number to an index into g_gpio (only for use in bbb_pin.c) + * If there is no index for that GPIO number, 128 is returned. + */ +const unsigned char g_pin_gpio_to_index[GPIO_MAX_NUMBER+1] = { + 128, 128, 128, 128, 0, 1, 128, 128, 2, 3, 4, 5, 128, 128, + 6, 7, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 8, 9, + 128, 128, 10, 11, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 12, 13, 14, 15, 16, 17, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 18, 19, 128, 128, 128, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 128, 128, + 128, 128, 37, 38, 39, 40, 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 41, 128, 128, 42 +}; + +/** + * Maps an index in g_gpio to the corresponding GPIO number. + */ +const unsigned char g_pin_index_to_gpio[GPIO_NUM_PINS] = { + 4, 5, 8, 9, 10, 11, 14, 15, 26, 27, 30, 31, 44, 45, + 46, 47, 48, 49, 60, 61, 65, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 77, 78, 79, 80, 81, 86, 87, 88, 89, 112, + 115 +}; + /** * Export a GPIO pin and open the file descriptors * @param pin The GPIO number to be exported @@ -474,7 +501,8 @@ bool ADC_Read(int id, int *value) if (pread(g_adc[id].fd_value, adc_str, ADC_DIGITS-1, 0) == -1) { - AbortBool("ADC %d read failed: %s", id, strerror(errno)); + //AbortBool("ADC %d read failed: %s", id, strerror(errno)); + return false; } *value = strtol(adc_str, NULL, 10); @@ -483,7 +511,7 @@ bool ADC_Read(int id, int *value) #ifndef _BBB //For running on systems that are not the BBB -bool True_Stub(void *arg, ...) { return true; } +bool True_Stub(int arg, ...) { return true; } bool ADC_Read_Stub(int *val, ...) { *val = 0; return true; } bool GPIO_Read_Stub(bool *val, ...) { *val = false; return true; } #endif