2017-10-01 03:39 AM
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.2017-10-01 05:44 AM
Use a cast? (GPIO_PinState)
((sa & 1) ? GPIO_PIN_SET : GPIO_PIN_RESET)
Bigger problem is you shift sa twice
2017-10-01 05:50 AM
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