X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=server%2Fbbb_pin.c;h=7d500dd0e44537e74d5e742adf872cfe3b26ddf0;hb=6f7034fea05d88dcf5a6b06c028b283922575b2a;hp=4d1276b1d7647cfcfcc733ab4b2f6808568b99a8;hpb=276903df90e1a0088832294749aca3fa56216697;p=matches%2FMCTX3420.git diff --git a/server/bbb_pin.c b/server/bbb_pin.c index 4d1276b..7d500dd 100644 --- a/server/bbb_pin.c +++ b/server/bbb_pin.c @@ -55,6 +55,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 @@ -272,7 +298,7 @@ bool ADC_Export(int pin) return true; } - sprintf(g_buffer, "%s/in_voltage%d_raw", g_options.adc_device_path, pin); + sprintf(g_buffer, "%s/in_voltage%d_raw", ADC_DEVICE_PATH, pin); g_adc[pin].fd_value = open(g_buffer, O_RDONLY); if (g_adc[pin].fd_value <0) { @@ -486,4 +512,4 @@ bool ADC_Read(int id, int *value) bool True_Stub(void *arg, ...) { return true; } bool ADC_Read_Stub(int *val, ...) { *val = 0; return true; } bool GPIO_Read_Stub(bool *val, ...) { *val = false; return true; } -#endif \ No newline at end of file +#endif