/* Will set up reference enable outputs according config */ void setReferences(void) { if (sns_inputAnalog_Config[0].RefEnable==CAN_MODULE_ENUM_INPUTANALOG_ANALOGCONFIG_REFERENCE_ENABLE) { #if sns_inputAnalog0RefPCA95xx==0 gpio_set_pin(sns_inputAnalog0Ref); gpio_set_out(sns_inputAnalog0Ref); #else Pca95xx_set_pin(sns_inputAnalog0Ref); Pca95xx_set_out(sns_inputAnalog0Ref); #endif } else { #if sns_inputAnalog0RefPCA95xx==0 gpio_clr_pin(sns_inputAnalog0Ref); gpio_set_out(sns_inputAnalog0Ref); #else Pca95xx_clr_pin(sns_inputAnalog0Ref); Pca95xx_set_out(sns_inputAnalog0Ref); #endif } #if sns_inputAnalog_NUM_SUPPORTED>=2 if (sns_inputAnalog_Config[1].RefEnable==CAN_MODULE_ENUM_INPUTANALOG_ANALOGCONFIG_REFERENCE_ENABLE) { #if sns_inputAnalog1RefPCA95xx==0 gpio_set_pin(sns_inputAnalog1Ref); gpio_set_out(sns_inputAnalog1Ref); #else Pca95xx_set_pin(sns_inputAnalog1Ref); Pca95xx_set_out(sns_inputAnalog1Ref); #endif } else { #if sns_inputAnalog1RefPCA95xx==0 gpio_clr_pin(sns_inputAnalog1Ref); gpio_set_out(sns_inputAnalog1Ref); #else Pca95xx_clr_pin(sns_inputAnalog1Ref); Pca95xx_set_out(sns_inputAnalog1Ref); #endif } #endif #if sns_inputAnalog_NUM_SUPPORTED>=3 if (sns_inputAnalog_Config[2].RefEnable==CAN_MODULE_ENUM_INPUTANALOG_ANALOGCONFIG_REFERENCE_ENABLE) { #if sns_inputAnalog2RefPCA95xx==0 gpio_set_pin(sns_inputAnalog2Ref); gpio_set_out(sns_inputAnalog2Ref); #else Pca95xx_set_pin(sns_inputAnalog2Ref); Pca95xx_set_out(sns_inputAnalog2Ref); #endif } else { #if sns_inputAnalog2RefPCA95xx==0 gpio_clr_pin(sns_inputAnalog2Ref); gpio_set_out(sns_inputAnalog2Ref); #else Pca95xx_clr_pin(sns_inputAnalog2Ref); Pca95xx_set_out(sns_inputAnalog2Ref); #endif } #endif #if sns_inputAnalog_NUM_SUPPORTED>=4 if (sns_inputAnalog_Config[3].RefEnable==CAN_MODULE_ENUM_INPUTANALOG_ANALOGCONFIG_REFERENCE_ENABLE) { #if sns_inputAnalog3RefPCA95xx==0 gpio_set_pin(sns_inputAnalog3Ref); gpio_set_out(sns_inputAnalog3Ref); #else Pca95xx_set_pin(sns_inputAnalog3Ref); Pca95xx_set_out(sns_inputAnalog3Ref); #endif } else { #if sns_inputAnalog3RefPCA95xx==0 gpio_clr_pin(sns_inputAnalog3Ref); gpio_set_out(sns_inputAnalog3Ref); #else Pca95xx_clr_pin(sns_inputAnalog3Ref); Pca95xx_set_out(sns_inputAnalog3Ref); #endif } #endif }
/* Will set up pullup enable outputs according config */ void setPullups(void) { if (sns_inputAnalog_Config[0].PullupEnable==CAN_MODULE_ENUM_INPUTANALOG_ANALOGCONFIG_PULLUP_ENABLE) { #if sns_inputAnalog0PullupPCA95xx==0 gpio_set_pin(sns_inputAnalog0Pullup); gpio_set_out(sns_inputAnalog0Pullup); #else Pca95xx_set_pin(sns_inputAnalog0Pullup); Pca95xx_set_out(sns_inputAnalog0Pullup); #endif } else { #if sns_inputAnalog0PullupPCA95xx==0 gpio_clr_pin(sns_inputAnalog0Pullup); gpio_set_out(sns_inputAnalog0Pullup); #else Pca95xx_clr_pin(sns_inputAnalog0Pullup); Pca95xx_set_out(sns_inputAnalog0Pullup); #endif } #if sns_inputAnalog_NUM_SUPPORTED>=2 if (sns_inputAnalog_Config[1].PullupEnable==CAN_MODULE_ENUM_INPUTANALOG_ANALOGCONFIG_PULLUP_ENABLE) { #if sns_inputAnalog1PullupPCA95xx==0 gpio_set_pin(sns_inputAnalog1Pullup); gpio_set_out(sns_inputAnalog1Pullup); #else Pca95xx_set_pin(sns_inputAnalog1Pullup); Pca95xx_set_out(sns_inputAnalog1Pullup); #endif } else { #if sns_inputAnalog1PullupPCA95xx==0 gpio_clr_pin(sns_inputAnalog1Pullup); gpio_set_out(sns_inputAnalog1Pullup); #else Pca95xx_clr_pin(sns_inputAnalog1Pullup); Pca95xx_set_out(sns_inputAnalog1Pullup); #endif } #endif #if sns_inputAnalog_NUM_SUPPORTED>=3 if (sns_inputAnalog_Config[2].PullupEnable==CAN_MODULE_ENUM_INPUTANALOG_ANALOGCONFIG_PULLUP_ENABLE) { #if sns_inputAnalog2PullupPCA95xx==0 gpio_set_pin(sns_inputAnalog2Pullup); gpio_set_out(sns_inputAnalog2Pullup); #else Pca95xx_set_pin(sns_inputAnalog2Pullup); Pca95xx_set_out(sns_inputAnalog2Pullup); #endif } else { #if sns_inputAnalog2PullupPCA95xx==0 gpio_clr_pin(sns_inputAnalog2Pullup); gpio_set_out(sns_inputAnalog2Pullup); #else Pca95xx_clr_pin(sns_inputAnalog2Pullup); Pca95xx_set_out(sns_inputAnalog2Pullup); #endif } #endif #if sns_inputAnalog_NUM_SUPPORTED>=4 if (sns_inputAnalog_Config[3].PullupEnable==CAN_MODULE_ENUM_INPUTANALOG_ANALOGCONFIG_PULLUP_ENABLE) { #if sns_inputAnalog3PullupPCA95xx==0 gpio_set_pin(sns_inputAnalog3Pullup); gpio_set_out(sns_inputAnalog3Pullup); #else Pca95xx_set_pin(sns_inputAnalog3Pullup); Pca95xx_set_out(sns_inputAnalog3Pullup); #endif } else { #if sns_inputAnalog3PullupPCA95xx==0 gpio_clr_pin(sns_inputAnalog3Pullup); gpio_set_out(sns_inputAnalog3Pullup); #else Pca95xx_clr_pin(sns_inputAnalog3Pullup); Pca95xx_set_out(sns_inputAnalog3Pullup); #endif } #endif }
void act_output_Init(void) { #if act_output_USEEEPROM==1 if (EEDATA_OK) { ///TODO: Use stored data to set initial values for the module uint8_t index = 0; #ifdef act_output_CH0 chnValue[index] = eeprom_read_byte(EEDATA.ch0); index++; #endif #ifdef act_output_CH1 chnValue[index] = eeprom_read_byte(EEDATA.ch1); index++; #endif #ifdef act_output_CH2 chnValue[index] = eeprom_read_byte(EEDATA.ch2); index++; #endif #ifdef act_output_CH3 chnValue[index] = eeprom_read_byte(EEDATA.ch3); index++; #endif #ifdef act_output_CH4 chnValue[index] = eeprom_read_byte(EEDATA.ch4); index++; #endif #ifdef act_output_CH5 chnValue[index] = eeprom_read_byte(EEDATA.ch5); index++; #endif #ifdef act_output_CH6 chnValue[index] = eeprom_read_byte(EEDATA.ch6); index++; #endif #ifdef act_output_CH7 chnValue[index] = eeprom_read_byte(EEDATA.ch7); index++; #endif #ifdef act_output_CH8 chnValue[index] = eeprom_read_byte(EEDATA.ch8); index++; #endif #ifdef act_output_CH9 chnValue[index] = eeprom_read_byte(EEDATA.ch9); index++; #endif } else { //The CRC of the EEPROM is not correct, store default values and update CRC #ifdef act_output_CH0 eeprom_write_byte_crc(EEDATA.ch0, 0x00, WITHOUT_CRC); #endif #ifdef act_output_CH1 eeprom_write_byte_crc(EEDATA.ch1, 0x00, WITHOUT_CRC); #endif #ifdef act_output_CH2 eeprom_write_byte_crc(EEDATA.ch2, 0x00, WITHOUT_CRC); #endif #ifdef act_output_CH3 eeprom_write_byte_crc(EEDATA.ch3, 0x00, WITHOUT_CRC); #endif #ifdef act_output_CH4 eeprom_write_byte_crc(EEDATA.ch4, 0x00, WITHOUT_CRC); #endif #ifdef act_output_CH5 eeprom_write_byte_crc(EEDATA.ch5, 0x00, WITHOUT_CRC); #endif #ifdef act_output_CH6 eeprom_write_byte_crc(EEDATA.ch6, 0x00, WITHOUT_CRC); #endif #ifdef act_output_CH7 eeprom_write_byte_crc(EEDATA.ch7, 0x00, WITHOUT_CRC); #endif #ifdef act_output_CH8 eeprom_write_byte_crc(EEDATA.ch8, 0x00, WITHOUT_CRC); #endif #ifdef act_output_CH9 eeprom_write_byte_crc(EEDATA.ch9, 0x00, WITHOUT_CRC); #endif EEDATA_UPDATE_CRC; } #endif ///Initialize hardware uint8_t index = 0; #if act_output_CH0PCA95xxIO==1 |act_output_CH1PCA95xxIO==1 | act_output_CH2PCA95xxIO==1 | act_output_CH3PCA95xxIO==1 | act_output_CH4PCA95xxIO==1 | act_output_CH5PCA95xxIO==1 | act_output_CH6PCA95xxIO==1 | act_output_CH7PCA95xxIO==1 Pca95xx_Init(0); #endif #ifdef act_output_CH0 #if act_output_CH0PCA95xxIO==0 gpio_set_statement(chnValue[index],act_output_CH0); gpio_set_out(act_output_CH0); #else Pca95xx_set_statement(chnValue[index],act_output_CH0); Pca95xx_set_out(act_output_CH0); #endif index++; #endif #ifdef act_output_CH1 #if act_output_CH1PCA95xxIO==0 gpio_set_statement(chnValue[index],act_output_CH1); gpio_set_out(act_output_CH1); #else Pca95xx_set_statement(chnValue[index],act_output_CH1); Pca95xx_set_out(act_output_CH1); #endif index++; #endif #ifdef act_output_CH2 #if act_output_CH2PCA95xxIO==0 gpio_set_statement(chnValue[index],act_output_CH2); gpio_set_out(act_output_CH2); #else Pca95xx_set_statement(chnValue[index],act_output_CH2); Pca95xx_set_out(act_output_CH2); #endif index++; #endif #ifdef act_output_CH3 #if act_output_CH3PCA95xxIO==0 gpio_set_statement(chnValue[index],act_output_CH3); gpio_set_out(act_output_CH3); #else Pca95xx_set_statement(chnValue[index],act_output_CH3); Pca95xx_set_out(act_output_CH3); #endif index++; #endif #ifdef act_output_CH4 #if act_output_CH4PCA95xxIO==0 gpio_set_statement(chnValue[index],act_output_CH4); gpio_set_out(act_output_CH4); #else Pca95xx_set_statement(chnValue[index],act_output_CH4); Pca95xx_set_out(act_output_CH4); #endif index++; #endif #ifdef act_output_CH5 #if act_output_CH5PCA95xxIO==0 gpio_set_statement(chnValue[index],act_output_CH5); gpio_set_out(act_output_CH5); #else Pca95xx_set_statement(chnValue[index],act_output_CH5); Pca95xx_set_out(act_output_CH5); #endif index++; #endif #ifdef act_output_CH6 #if act_output_CH6PCA95xxIO==0 gpio_set_statement(chnValue[index],act_output_CH6); gpio_set_out(act_output_CH6); #else Pca95xx_set_statement(chnValue[index],act_output_CH6); Pca95xx_set_out(act_output_CH6); #endif index++; #endif #ifdef act_output_CH7 #if act_output_CH7PCA95xxIO==0 gpio_set_statement(chnValue[index],act_output_CH7); gpio_set_out(act_output_CH7); #else Pca95xx_set_statement(chnValue[index],act_output_CH7); Pca95xx_set_out(act_output_CH7); #endif index++; #endif #ifdef act_output_CH8 #if act_output_CH8PCA95xxIO==0 gpio_set_statement(chnValue[index],act_output_CH8); gpio_set_out(act_output_CH8); #else Pca95xx_set_statement(chnValue[index],act_output_CH8); Pca95xx_set_out(act_output_CH8); #endif index++; #endif #ifdef act_output_CH9 #if act_output_CH9PCA95xxIO==0 gpio_set_statement(chnValue[index],act_output_CH9); gpio_set_out(act_output_CH9); #else Pca95xx_set_statement(chnValue[index],act_output_CH9); Pca95xx_set_out(act_output_CH9); #endif index++; #endif }