static void prvEEPROMTask(void *pvParameters) { const uint32_t ulMaxDelay = 10000UL / portTICK_RATE_MS; (void) pvParameters; for (;;) { // FreeRTOS_ioctl(xI2CPort, ioctlRELEASE_WRITE_MUTEX, // i2cPARAMETER_NOT_USED ); /* Write and read-back operations are to be performed on the EEPROM while the I2C bus is in interrupt driven zero copy Tx, and interrupt driven circular buffer Rx mode. Indicate this on the OLED. */ if (xSemaphoreTake( xOLEDMutex, portMAX_DELAY ) == pdTRUE) { vI2C_OLEDInitialize(xI2CPort); vOLEDPutString(0U, (uint8_t *) "Testing EEPROM", OLED_COLOR_WHITE, OLED_COLOR_BLACK); vOLEDPutString(oledCHARACTER_HEIGHT, (uint8_t *) "in intrpt mode", OLED_COLOR_WHITE, OLED_COLOR_BLACK); /* Using zero copy Tx mode means the write mutex must be obtained prior to calling vOLEDRefreshDisplay(). The write mutex is retained when vOLEDRefreshDisplay() returns. */ vOLEDRefreshDisplay(); /* Perform the interrupt driven mode EEPROM tests/examples. */ vI2C_EEPROMTest(xI2CPort); xSemaphoreGive(xOLEDMutex); } vTaskDelay(ulMaxDelay); } }
static void prvI2CTask( void *pvParameters ) { Peripheral_Descriptor_t xI2CPort; const uint32_t ulMaxDelay = 500UL / portTICK_RATE_MS; ( void ) pvParameters; /* Open the I2C port used for writing to both the OLED and the EEPROM. The second parameter (ulFlags) is not used in this case. The port is opened in polling mode. It is changed to interrupt driven mode later in this function. */ xI2CPort = FreeRTOS_open( boardOLED_I2C_PORT, ( uint32_t ) i2cPARAMETER_NOT_USED ); configASSERT( xI2CPort ); /* The OLED must be initialised before it is used. */ vI2C_OLEDInitialise( xI2CPort ); /* Write and read-back operations are to be performed on the EEPROM while the I2C bus is in polling mode. Indicate this on the OLED. */ vOLEDPutString( 0U, ( uint8_t * ) "Testing EEPROM", OLED_COLOR_WHITE, OLED_COLOR_BLACK ); vOLEDPutString( oledCHARACTER_HEIGHT, ( uint8_t * ) "in polling mode", OLED_COLOR_WHITE, OLED_COLOR_BLACK ); vOLEDRefreshDisplay(); /* Perform the polling mode EEPROM tests/examples. */ vI2C_EEPROMTest( xI2CPort ); /* Perform the polling mode OLED write example. */ vI2C_OLEDTest( xI2CPort, ( uint8_t * ) "in polling mode" ); /* Switch to interrupt driven zero copy Tx mode and interrupt driven circular buffer Rx mode (with a limited time out). */ FreeRTOS_ioctl( xI2CPort, ioctlUSE_ZERO_COPY_TX, i2cPARAMETER_NOT_USED ); FreeRTOS_ioctl( xI2CPort, ioctlUSE_CIRCULAR_BUFFER_RX, i2cCIRCULAR_BUFFER_SIZE ); FreeRTOS_ioctl( xI2CPort, ioctlSET_RX_TIMEOUT, i2c200MS_TIMEOUT ); /* By default, the I2C interrupt priority will have been set to the lowest possible. It must be kept at or below configMAX_LIBRARY_INTERRUPT_PRIORITY, but can be raised above its default priority using a FreeRTOS_ioctl() call with the ioctlSET_INTERRUPT_PRIORITY command. */ FreeRTOS_ioctl( xI2CPort, ioctlSET_INTERRUPT_PRIORITY, ( void * ) ( configMIN_LIBRARY_INTERRUPT_PRIORITY - 1 ) ); /* Write and read-back operations are to be performed on the EEPROM while the I2C bus is in interrupt driven zero copy Tx, and interrupt driven circular buffer Rx mode. Indicate this on the OLED. */ vOLEDPutString( 0U, ( uint8_t * ) "Testing EEPROM", OLED_COLOR_WHITE, OLED_COLOR_BLACK ); vOLEDPutString( oledCHARACTER_HEIGHT, ( uint8_t * ) "in intrpt mode", OLED_COLOR_WHITE, OLED_COLOR_BLACK ); /* Using zero copy Tx mode means the write mutex must be obtained prior to calling vOLEDRefreshDisplay(). The write mutex is retained when vOLEDRefreshDisplay() returns. */ FreeRTOS_ioctl( xI2CPort, ioctlOBTAIN_WRITE_MUTEX, ( void * ) ulMaxDelay ); vOLEDRefreshDisplay(); /* Perform the interrupt driven mode EEPROM tests/examples. */ vI2C_EEPROMTest( xI2CPort ); /* Finish off by just continuously writing a scrolling message to the OLED. */ for( ;; ) { vI2C_OLEDTest( xI2CPort, ( uint8_t * ) "in intrpt mode" ); } }