cancel
Showing results for 
Search instead for 
Did you mean: 

How to write HAL_GPIO_Writebit?

kemal
Associate II
Posted on October 01, 2017 at 12:39

Hi.

How to write  HAL_GPIO_Writebit ? 

how to write MOSI_PIN = sa value?

void Write_Cmd_Data (unsigned char sa)

{

unsigned int i;

DC_SET;

delayms(10);

CS_RESET;

delayms(10);

for (i = 0; i < 8; i++, sa >>= 1) {

//HAL_GPIO_WritePin(GPIOA,MOSI_PIN, (sa>>i)&0x01);// ????????

delayms(10);

SCLK_SET //clk=1;

delayms(10);

SCLK_RESET //clk=0;

}

CS_SET //=1;

delayms(10);

}

it gives a warning.

.. \ Src \ main.c (186): warning: # 188-D: enumerated type mixed with another type

Thank you.
2 REPLIES 2
Posted on October 01, 2017 at 14:44

Use a cast? (GPIO_PinState)

((sa & 1) ? GPIO_PIN_SET : GPIO_PIN_RESET)

Bigger problem is you shift sa twice

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
john doe
Lead
Posted on October 01, 2017 at 14:50

not sure what you're trying to accomplish.  the third argument to HAL_GPIO_WritePin() is going to be either GPIO_PIN_SET or GPIO_PIN_RESET

HAL_GPIO_WritePin(GPIOA,MOSI_PIN,GPIO_PIN_RESET); will set MOSI_PIN to low

HAL_GPIO_WritePin(GPIOA,MOSI_PIN,GPIO_PIN_SET); will set MOSI_PIN high