X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=server%2Fbbb_pin_defines.h;h=7ccda87de950b238026fc81a2b922d5979029ada;hb=HEAD;hp=dba2d5c9588e35be8b1d37fc1a9e51c28adc34de;hpb=0c55febb46bf3bfacaeefda0a2e422b42c18710c;p=matches%2FMCTX3420.git diff --git a/server/bbb_pin_defines.h b/server/bbb_pin_defines.h index dba2d5c..7ccda87 100644 --- a/server/bbb_pin_defines.h +++ b/server/bbb_pin_defines.h @@ -6,12 +6,14 @@ #ifndef _BBB_PIN_DEFINES_H #define _BBB_PIN_DEFINES_H -/** GPIO0 defines **/ +/** The number of expansion pins on the BBB **/ +#define BBB_PIN_COUNT 92 +/** GPIO0 defines **/ #define GPIO0_1 1 -#define GPIO0_2 2 -//#define GPIO0_3 3 // Used for PWM -//#define GPIO0_4 4 // Used for PWM +#define GPIO0_2 2 // Used for PWM +#define GPIO0_3 3 // Used for PWM +#define GPIO0_4 4 #define GPIO0_5 5 #define GPIO0_6 6 #define GPIO0_7 7 @@ -111,12 +113,18 @@ #define GPIO2_31 95 #define GPIO2_32 96 -/** Number of GPIO pins **/ -#define GPIO_NUM_PINS 97 - /** Export path **/ #define GPIO_DEVICE_PATH "/sys/class/gpio" +/** Number of useable GPIO pins **/ +#define GPIO_NUM_PINS 43 +/** The max usable GPIO number **/ +#define GPIO_MAX_NUMBER 115 + +/* Luts */ +extern const unsigned char g_pin_gpio_to_index[GPIO_MAX_NUMBER+1]; +extern const unsigned char g_pin_index_to_gpio[GPIO_NUM_PINS]; + #define ADC_BITS 12 #define ADC_DIGITS 5 #define ADC0 0 @@ -127,28 +135,34 @@ #define ADC5 5 #define ADC6 6 #define ADC7 7 +/** The maximum voltage input to the ADC **/ +#define ADC_VOLTAGE_MAX 1800 +/** The maximum raw value from the ADC **/ +#define ADC_RAW_MAX (2 << ADC_BITS) +/** Converts the raw ADC value to a voltage in millivolts **/ +#define ADC_TO_MVOLTS(x) ((double)((x)/2 << ADC_BITS) * (double)ADC_VOLTAGE_MAX) /** Number of ADC pins **/ #define ADC_NUM_PINS 8 - -/** Path to export ADCs with**/ -#define ADC_EXPORT_PATH "/sys/devices/bone_capemgr.9/slots" -/** Path at which ADCs appear **/ -#define ADC_DEVICE_PATH "/sys/devices/ocp.3/helper.16" - -/** PWM defines **/ -#define EHRPWM0A 0 -#define EHRPWM0B 1 -// No other PWM pins work! +/** The path to the ADCs on the BBB **/ +#define ADC_DEVICE_PATH "/sys/bus/iio/devices/iio:device0/" + +/** PWM names to sysfs numbers **/ +#define EHRPWM0A 0 //P9_22 +#define EHRPWM0B 1 //P9_21 - period paired with EHRPWM0A +#define EHRPWM1A 3 //P9_14 +#define EHRPWM1B 4 //P9_16 - period paired with EHRPWM1A +#define ECAP0 2 //P9_42 +#define ECAP2 7 //P9_28 +#define EHRPWM2A 5 //P8_19 +#define EHRPWM2B 6 //P8_13 - period paired with EHRPWM2A /** Number of PWM pins **/ -#define PWM_NUM_PINS 2 +#define PWM_NUM_PINS 8 /** Path to PWM sysfs **/ #define PWM_DEVICE_PATH "/sys/class/pwm" - - #endif //_BBB_PIN_DEFINES_H