inline std_return RTE_Output_SetOutput_OSPort_Out(const char* message) { #ifdef RTE_Output_SetOutput_OSPort_Out_DISPLAY print(message); #endif #ifdef RTE_Output_SetOutput_OSPort_Out_IIC uint8_t data_IIC = 0x5F; /* wenn 0 auf ein LED ausgegeben wird, dann leuchtet eine LED, wobei die ersten 4 bit entscheiden */ // static uint8_t IIC_Initialized = 0; // if(!IIC_Initialized) // { // IIC_Initialized = 1; // i2c_enable(RTE_Output_SetOutput_OSPort_Out_PORT); // } while(i2c_busy(RTE_Output_SetOutput_OSPort_Out_PORT) != 0); ecrobot_send_i2c(RTE_Output_SetOutput_OSPort_Out_PORT, 0x20, data_IIC, &data_IIC, 0); #endif return 0; }
inline std_return RTE_StopSensor_GetSensorValue_OSPort_In(uint8_t* value) { static uint8_t IIC_Initialized = 0; #ifdef RTE_StopSensor_GetSensorValue_OSPort_In_BUTTON /* als Abbruchbedingung ist ein Button definiert */ uint8_t currentStatus = ecrobot_get_touch_sensor(RTE_StopSensor_GetSensorValue_OSPort_In_PORT); static uint8_t driverButtonLastState = 0; if ( currentStatus != driverButtonLastState && currentStatus != 0) { /* Button is gedrückt */ *value = 1; } else { /* Button nicht gedrückt */ *value = 0; } driverButtonLastState = currentStatus; #endif #ifdef RTE_StopSensor_GetSensorValue_OSPort_In_IIC /* als Abbruchbedingung ist der IIC definiert */ static uint8_t currentStatus_StopSensor = 0xFF; // if(!IIC_Initialized) // { // IIC_Initialized = 1; // i2c_enable(RTE_StopSensor_GetSensorValue_OSPort_In_PORT); // } ecrobot_send_i2c(RTE_StopSensor_GetSensorValue_OSPort_In_PORT, 0x20, currentStatus, ¤tStatus, 0); while(i2c_busy(RTE_StopSensor_GetSensorValue_OSPort_In_PORT) != 0); ecrobot_read_i2c(RTE_StopSensor_GetSensorValue_OSPort_In_PORT, 0x20, 0xF0, ¤tStatus, 1); if((currentStatus == 0xD0) || (currentStatus == 0xE0)) { *value = 1; } else { *value = 0; } #endif return 0; }