/* Private functions ---------------------------------------------------------*/ void prvLcdWaitUntilNotBusy(void) { ePinState_t eBusyFlag = ePinHigh; /*Set data pin 7 as input */ vGpioSetPinMode(xLcdInfo.xDataPin[7].ucID,eInputModeNoPu); /*Reset register pin */ vGpioSetPinState(xLcdInfo.xRegisterPin.ucID, ePinLow); /*Set Read/write pin */ vGpioSetPinState(xLcdInfo.xReadWritePin.ucID, ePinHigh); do { /*Set Enable pin */ vGpioSetPinState(xLcdInfo.xEnablePin.ucID, ePinHigh); /*Read the data pin 7*/ eBusyFlag = eGpioReadPinState(xLcdInfo.xDataPin[7].ucID); /*Reset Enable pin */ vGpioSetPinState(xLcdInfo.xEnablePin.ucID, ePinLow); } while(eBusyFlag == ePinHigh) /*Set data pin 7 as output */ vGpioSetPinMode(xLcdInfo.xDataPin[7].ucID,eOutputMode); }
/* main ===================================================================== */ int main (void) { vGpioSetPinMode (LED1, eModeOutput); // broche led en sortie vGpioSetPinMode (BUTTON, eModeInputPullUp); // broche bouton en entrée avec pull-up // avec le mode eModeInputPullUp, bGpioRead() retourne true si le signal est à 0 // fait clignoter la LED1 16 fois for (int i = 0; i < 16; i++) { vGpioWrite (LED1, 1); // on allume la led delay_ms (50); // pendant 50ms vGpioWrite (LED1, 0); // puis on l'éteint delay_ms (150); // pendant 150ms } for (;;) { if (bGpioRead (BUTTON)) { // si bouton appuyé vGpioToggle (LED1); // on bascule la led delay_ms (200); } } return 0; }
void LcdInit(void) { uint8_t uci; /*Set the number of data pin*/ if(xLcdInfo.eLcdMode == eMode4bData) ucLcdNumDataPin = 4; else ucLcdNumDataPin = 8; /*Set pins mode*/ vGpioSetPinMode(xLcdInfo.xEnablePin.ucID, eOutputMode); vGpioSetPinMode(xLcdInfo.xRegisterPin.ucID, eOutputMode); vGpioSetPinMode(xLcdInfo.xReadWritePin.ucID, eOutputMode); for(uci = 0; uci < ucLcdNumDataPin; uci++) vGpioSetPinMode(xLcdInfo.xDataPin[uci].ucID, eOutputMode); }