39 #ifdef oC_LCDTFT_LLD_AVAILABLE 46 #define _________________________________________DRIVER_DEFINITIONS_SECTION_________________________________________________________________ 51 #define DRIVER_NAME LCDTFT 52 #define DRIVER_FILE_NAME "lcdtft" 53 #define DRIVER_TYPE GRAPHICS_DRIVER 54 #define DRIVER_VERSION oC_Driver_MakeVersion(1,0,0) 55 #define REQUIRED_DRIVERS &GPIO 56 #define REQUIRED_BOOT_LEVEL oC_Boot_Level_RequireMemoryManager | oC_Boot_Level_RequireDriversManager 59 #define DRIVER_CONFIGURE oC_LCDTFT_Configure 60 #define DRIVER_UNCONFIGURE oC_LCDTFT_Unconfigure 61 #define DRIVER_TURN_ON oC_LCDTFT_TurnOn 62 #define DRIVER_TURN_OFF oC_LCDTFT_TurnOff 63 #define IS_TURNED_ON oC_LCDTFT_IsTurnedOn 64 #define HANDLE_IOCTL oC_LCDTFT_Ioctl 65 #define READ_COLOR_MAP oC_LCDTFT_ReadColorMap 66 #define SET_RESOLUTION oC_LCDTFT_SetResolution 67 #define READ_RESOLUTION oC_LCDTFT_ReadResolution 69 #undef _________________________________________DRIVER_DEFINITIONS_SECTION_________________________________________________________________ 79 #define _________________________________________TYPES_SECTION______________________________________________________________________________ 98 bool ColorMapAllocated;
101 #undef _________________________________________TYPES_SECTION______________________________________________________________________________ 110 #define _________________________________________VARIABLES_SECTION__________________________________________________________________________ 121 #undef _________________________________________VARIABLES_SECTION__________________________________________________________________________ 128 #define _________________________________________LOCAL_PROTOTYPES_SECTION___________________________________________________________________ 134 #undef _________________________________________LOCAL_PROTOTYPES_SECTION___________________________________________________________________ 141 #define _________________________________________INTERFACE_FUNCTIONS_SECTION________________________________________________________________ 155 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
161 if(errorCode == oC_ErrorCode_ModuleIsTurnedOn)
163 errorCode = oC_ErrorCode_None;
166 if(!oC_ErrorOccur(errorCode))
170 errorCode = oC_ErrorCode_None;
189 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
198 if(errorCode == oC_ErrorCode_ModuleNotStartedYet)
200 errorCode = oC_ErrorCode_None;
233 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
238 ErrorCondition( isram(Config) || isrom(Config) , oC_ErrorCode_WrongConfigAddress ) &&
239 ErrorCondition( isram(outContext) , oC_ErrorCode_OutputAddressNotInRAM ) &&
240 ErrorCondition( Config->Width > 0 && Config->Height > 0 , oC_ErrorCode_ResolutionNotSet )
243 oC_IntMan_EnterCriticalSection();
246 oC_AssignErrorCode(&errorCode ,
Context_New(Config,&context) ) &&
253 oC_AssignErrorCode(&errorCode ,
oC_LCDTFT_LLD_SetPolarities(Config->HSyncPolarity,Config->VSyncPolarity,Config->DESyncPolarity) ) &&
260 *outContext = context;
261 errorCode = oC_ErrorCode_None;
265 oC_SaveIfErrorOccur(
"LCDTFT-Configure: Error while deleting context - " ,
Context_Delete(&context));
267 oC_IntMan_ExitCriticalSection();
288 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
293 ErrorCondition( isaddresscorrect(Config) , oC_ErrorCode_WrongConfigAddress) &&
294 ErrorCondition( isram(outContext) , oC_ErrorCode_OutputAddressNotInRAM) &&
295 ErrorCondition(
IsContextCorrect(*outContext) , oC_ErrorCode_ContextNotCorrect )
304 errorCode = oC_ErrorCode_None;
327 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
331 ErrorCondition( isaddresscorrect(Context) , oC_ErrorCode_WrongAddress ) &&
332 ErrorCondition( oC_Ioctl_IsCorrectCommand(Command) , oC_ErrorCode_CommandNotCorrect ) &&
333 ErrorCondition(
IsContextCorrect(Context) , oC_ErrorCode_ContextNotCorrect )
344 errorCode = oC_ErrorCode_CommandNotHandled;
354 oC_ErrorCode_t oC_LCDTFT_SetBackgroundColor(
oC_LCDTFT_Context_t Context , oC_Color_t Color , oC_ColorFormat_t ColorFormat )
356 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
361 ErrorCondition(
IsContextCorrect(Context) , oC_ErrorCode_ContextNotCorrect ) &&
362 ErrorCondition( oC_Color_IsCorrect(Color) , oC_ErrorCode_ColorNotCorrect ) &&
363 ErrorCondition( oC_ColorFormat_IsCorrect(ColorFormat) , oC_ErrorCode_ColorFormatNotCorrect )
375 oC_ErrorCode_t oC_LCDTFT_ReadBackgroundColor(
oC_LCDTFT_Context_t Context , oC_Color_t * outColor , oC_ColorFormat_t ColorFormat )
377 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
382 ErrorCondition(
IsContextCorrect(Context) , oC_ErrorCode_ContextNotCorrect ) &&
383 ErrorCondition( isram(outColor) , oC_ErrorCode_OutputAddressNotInRAM ) &&
384 ErrorCondition( oC_ColorFormat_IsCorrect(ColorFormat) , oC_ErrorCode_ColorFormatNotCorrect )
397 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
402 ErrorCondition(
IsContextCorrect(Context) , oC_ErrorCode_ContextNotCorrect ) &&
403 ErrorCondition( isram(outColorMap) , oC_ErrorCode_OutputAddressNotInRAM )
406 *outColorMap = Context->ColorMap;
407 errorCode = oC_ErrorCode_None;
416 oC_ErrorCode_t oC_LCDTFT_SetResolution(
oC_LCDTFT_Context_t Context , oC_Pixel_ResolutionUInt_t Width , oC_Pixel_ResolutionUInt_t Height )
418 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
423 ErrorCondition(
IsContextCorrect(Context) , oC_ErrorCode_ContextNotCorrect ) &&
430 errorCode = oC_ErrorCode_None;
439 oC_ErrorCode_t oC_LCDTFT_ReadResolution(
oC_LCDTFT_Context_t Context , oC_Pixel_ResolutionUInt_t * outWidth , oC_Pixel_ResolutionUInt_t * outHeight )
441 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
446 ErrorCondition(
IsContextCorrect(Context) , oC_ErrorCode_ContextNotCorrect ) &&
447 ErrorCondition( isram(outWidth) , oC_ErrorCode_OutputAddressNotInRAM ) &&
448 ErrorCondition( isram(outHeight) , oC_ErrorCode_OutputAddressNotInRAM )
458 #undef _________________________________________INTERFACE_FUNCTIONS_SECTION________________________________________________________________ 465 #define _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________ 484 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
485 oC_LCDTFT_Context_t context = kmalloc(
sizeof(
struct Context_t) , &Allocator , AllocationFlags_CanWait1Second | AllocationFlags_ZeroFill );
487 if(ErrorCondition(context !=
NULL , oC_ErrorCode_AllocationError))
489 context->ConstColorMap = Config->ColorMap;
490 context->ColorMapAllocated =
false;
492 if(context->ColorMap ==
NULL)
494 context->ColorMap = oC_ColorMap_New(&Allocator,AllocationFlags_CanWait1Second | AllocationFlags_ExternalRamFirst ,Config->Width,Config->Height,Config->ColorFormat);
495 context->ColorMapAllocated =
true;
498 if(ErrorCondition(context->ColorMap !=
NULL , oC_ErrorCode_AllocationError ) &&
499 ErrorCondition(oC_ColorMap_IsCorrect(context->ColorMap) , oC_ErrorCode_ColorMapNotCorrect )
502 *outContext = context;
504 errorCode = oC_ErrorCode_None;
510 oC_SaveIfErrorOccur(
"Context_New: Delete context error: " ,
Context_Delete(&context));
525 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
528 errorCode = oC_ErrorCode_None;
530 if(context->ColorMapAllocated)
532 if(!oC_ColorMap_Delete(context->ColorMap,AllocationFlags_CanWaitForever))
534 errorCode = oC_ErrorCode_ReleaseError;
537 if(!kfree(context,AllocationFlags_CanWaitForever))
539 errorCode = oC_ErrorCode_ReleaseError;
545 #undef _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________ oC_ErrorCode_t oC_LCDTFT_LLD_SetTimingParameters(const oC_LCDTFT_LLD_TimingParameters_t *TimingParameters)
oC_ErrorCode_t oC_LCDTFT_LLD_SetBackgroundColor(oC_Color_t Color, oC_ColorFormat_t ColorFormat)
oC_ErrorCode_t oC_LCDTFT_TurnOff(void)
Turns off the LCDTFT driver.
oC_ErrorCode_t oC_LCDTFT_LLD_RestoreDefaultState(void)
oC_ErrorCode_t oC_LCDTFT_LLD_EnableOperations(void)
static oC_ErrorCode_t Context_New(const oC_LCDTFT_Config_t *Config, oC_LCDTFT_Context_t *outContext)
oC_ErrorCode_t oC_LCDTFT_LLD_SetPixelFormat(oC_ColorFormat_t PixelFormat)
static oC_ErrorCode_t Context_Delete(oC_LCDTFT_Context_t *outContext)
The file with interface for the GPIO driver.
oC_ErrorCode_t oC_LCDTFT_Ioctl(oC_LCDTFT_Context_t Context, oC_Ioctl_Command_t Command, void *Data)
handles input/output driver commands
oC_ErrorCode_t oC_LCDTFT_LLD_SetResolution(oC_Pixel_ResolutionUInt_t Width, oC_Pixel_ResolutionUInt_t Height)
identifier for allocations
The file with interface for LCDTFT driver.
The file contains definitions for the compiler, that helps to manage errors, etc. ...
oC_ErrorCode_t oC_LCDTFT_LLD_SetPower(oC_Power_t Power)
oC_ErrorCode_t oC_LCDTFT_LLD_SetColormapBuffer(const void *Buffer)
static const oC_Allocator_t Allocator
oC_ErrorCode_t oC_LCDTFT_LLD_SetPolarities(oC_LCDTFT_LLD_Polarity_t HSyncPolarity, oC_LCDTFT_LLD_Polarity_t VSyncPolarity, oC_LCDTFT_LLD_Polarity_t DataEnablePolarity)
oC_ErrorCode_t oC_LCDTFT_Configure(const oC_LCDTFT_Config_t *Config, oC_LCDTFT_Context_t *outContext)
configures LCDTFT pins to work
The file with interface for driver creating.
The file with interface for the module library.
static bool oC_Module_IsTurnedOn(oC_Module_t Module)
checks if the module is turned on
uint32_t oC_ObjectControl_t
stores object control value
oC_ErrorCode_t oC_LCDTFT_TurnOn(void)
turns on the module
The file with interface for interrupt manager.
oC_ErrorCode_t oC_LCDTFT_LLD_ReadResolution(oC_Pixel_ResolutionUInt_t *outWidth, oC_Pixel_ResolutionUInt_t *outHeight)
oC_ErrorCode_t oC_LCDTFT_LLD_TurnOffDriver(void)
oC_ErrorCode_t oC_LCDTFT_LLD_TurnOnDriver(void)
static oC_ObjectControl_t oC_CountObjectControl(void *ObjectPointer, oC_ObjectId_t ObjectId)
counts object control for object
static bool oC_CheckObjectControl(void *ObjectPointer, oC_ObjectId_t ObjectId, oC_ObjectControl_t ObjectControl)
checks if object control is correct
oC_ErrorCode_t oC_LCDTFT_LLD_DisconnectPins(const oC_LCDTFT_LLD_Pins_t *Pins)
oC_ErrorCode_t oC_LCDTFT_LLD_ConnectPins(const oC_LCDTFT_LLD_Pins_t *Pins)
static void oC_Module_TurnOn(oC_Module_t Module)
sets module as turned on
oC_ObjectControl_t ObjectControl
static bool oC_Module_TurnOffVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned off
oC_ErrorCode_t oC_LCDTFT_LLD_SetPixelClockPolarity(oC_LCDTFT_LLD_PixelClockPolarity_t PixelPolarity)
Definition of the null pointer.
static bool oC_Module_TurnOnVerification(oC_ErrorCode_t *outErrorCode, oC_Module_t Module)
verify if module is turned on
oC_ErrorCode_t oC_LCDTFT_Unconfigure(const oC_LCDTFT_Config_t *Config, oC_LCDTFT_Context_t *outContext)
Unconfigures the driver.
oC_ErrorCode_t oC_LCDTFT_LLD_SetFrequency(oC_Frequency_t Frequency, oC_Frequency_t PermissibleDifference)
oC_ErrorCode_t oC_LCDTFT_LLD_ReadBackgroundColor(oC_Color_t *outColor, oC_ColorFormat_t ColorFormat)
LCDTFT driver configuration structure.
The file with LLD interface for the LCDTFT driver.
bool oC_LCDTFT_IsTurnedOn(void)
checks if the driver is turned on
static bool IsContextCorrect(oC_LCDTFT_Context_t Context)
Checks if the context of the LCDTFT driver is correct.
oC_ErrorCode_t oC_LCDTFT_LLD_DisableOperations(void)
#define NULL
pointer to a zero
static void oC_Module_TurnOff(oC_Module_t Module)
sets module as turned off