#ifndef _AVM_HW_CONFIG_H_ #define _AVM_HW_CONFIG_H_ #define AVM_HW_CONFIG_VERSION 1 #include #include enum _avm_hw_param { avm_hw_param_no_param = AVM_DEF_HW_PARAM_NO_PARAM, avm_hw_param_gpio_out_active_low = AVM_DEF_HW_PARAM_GPIO_OUT_ACTIVE_LOW, avm_hw_param_gpio_out_active_high = AVM_DEF_HW_PARAM_GPIO_OUT_ACTIVE_HIGH, avm_hw_param_gpio_in_active_low = AVM_DEF_HW_PARAM_GPIO_IN_ACTIVE_LOW, avm_hw_param_gpio_in_active_high = AVM_DEF_HW_PARAM_GPIO_IN_ACTIVE_HIGH, avm_hw_param_gpio_out_rgb = AVM_DEF_HW_PARAM_GPIO_OUT_RGB, avm_hw_param_gpio_out_rgb_active_low = AVM_DEF_HW_PARAM_GPIO_OUT_RGB_ACTIVE_LOW, avm_hw_param_last_param }; struct _avm_hw_config { char *name; int value; enum _avm_hw_param param; }; struct _avm_hw_config_table { unsigned int hwrev; unsigned int hwsubrev; struct _avm_hw_config *table; }; extern struct _avm_hw_config *avm_current_hw_config; int init_gpio_config(void); struct _avm_hw_config *avm_get_hw_config_table(void); /**--------------------------------------------------------------------------------**\ \**--------------------------------------------------------------------------------**/ static inline struct _avm_hw_config *_avm_get_hw_configstruct(const char *name) { unsigned i; if(!avm_current_hw_config) { avm_current_hw_config = avm_get_hw_config_table(); if(!avm_current_hw_config) return NULL; } for(i = 0; avm_current_hw_config[i].name; i++) { if(strcmp(avm_current_hw_config[i].name, name) == 0) { return &avm_current_hw_config[i]; } } return NULL; } /*------------------------------------------------------------------------------------------*\ * Config-Wert name nicht gefunden: * return -1, p_value & p_param nicht gültig * version != AVM_HW_CONFIG_VERSION: * return -2, p_value & p_param nicht gültig * sonst: * return 0 \*------------------------------------------------------------------------------------------*/ static inline int avm_get_hw_config(unsigned int version, const char *name, int *p_value, enum _avm_hw_param *p_param) { struct _avm_hw_config *phwconfig; if(version != AVM_HW_CONFIG_VERSION) { return -2; } phwconfig = _avm_get_hw_configstruct(name); if(phwconfig == NULL) { return -1; } if (p_value) *p_value = phwconfig->value; if(p_param) *p_param = phwconfig->param; return 0; } #endif /*--- #ifndef _AVM_HW_CONFIG_H_ ---*/