Skip to main content
kemal
Associate III
October 1, 2017
Question

How to write HAL_GPIO_Writebit?

  • October 1, 2017
  • 2 replies
  • 951 views
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.
    This topic has been closed for replies.

    2 replies

    Tesla DeLorean
    Guru
    October 1, 2017
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    john doe
    Senior III
    October 1, 2017
    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