AnsweredAssumed Answered

Drive Pins or Port with MQX (TWRMCF51MM256)

Question asked by Daniele Cortellazzi on Sep 5, 2013
Latest reply on Sep 10, 2013 by Daniele Cortellazzi

Hi all, i have some question with the use of gpio with mqx. I have to drive some pin for control a LCD with parallel interface. I have created some struct :

 

const uint_32 control_pin[] =

{

BSP_LCD_CS | GPIO_PIN_STATUS_0,

BSP_LCD_WR | GPIO_PIN_STATUS_0,

BSP_LCD_RS | GPIO_PIN_STATUS_0,

GPIO_LIST_END

};

 

 

and

 

 

const uint_32 data_pin[] =

{

BSP_LCD_D0 | GPIO_PIN_STATUS_0,

BSP_LCD_D1 | GPIO_PIN_STATUS_0,

BSP_LCD_D2 | GPIO_PIN_STATUS_0,

BSP_LCD_D3 | GPIO_PIN_STATUS_0,

BSP_LCD_D4 | GPIO_PIN_STATUS_0,

BSP_LCD_D5 | GPIO_PIN_STATUS_0,

BSP_LCD_D6 | GPIO_PIN_STATUS_0,

BSP_LCD_D7 | GPIO_PIN_STATUS_0,

GPIO_LIST_END

};

 

 

now i have to command this pins. i have create only a struct for the control_pin and one for the data_pin. I have then to set the control_pin and after pass the data to the data_pin

 

 

FILE_PTR control_file = fopen(“gpio:output”, &control_pin);

FILE_PTR data_file = fopen(“gpio:output”, &data_pin);

 

 

now i want to set the pin CS, WR and RS but with different value then i have try this operation

 

 

ioctl(control_file, GPIO_IOCTL_WRITE , &control_pin[CS]);

ioctl(control_file, GPIO_IOCTL_WRITE , &control_pin[WR]);

ioctl(control_file, GPIO_IOCTL_WRITE , &control_pin[RD]);

 

 

i want to write 1 or 0 to a specific pin of the struct control_pin without create three different struct, is possible??

 

 

after that i have to pass a variable data to the data_pin then, is right do this ??

 

 

ioctl(data_file, GPIO_IOCTL_WRITE_LOG1 , &data);

 

 

Please help me, i'm at the begin so i have many difficulties to use mqx. Thanks all!!

Outcomes