Author Topic: STP1612PW05 LED driver  (Read 457 times)

0 Members and 1 Guest are viewing this topic.

Offline alizare368Topic starter

  • Regular Contributor
  • *
  • Posts: 56
  • Country: de
STP1612PW05 LED driver
« on: June 18, 2019, 02:22:31 pm »
Hi
 I used these codes to run the RGB LED DRIVER(stp1612pw05), but it does not work.
Code: [Select]

#define SPI_SCLK_LOW_TIME  200
#define SPI_SCLK_HIGH_TIME 1

uint16_t SPI_1(uint16_t byte_out)
{
  uint16_t byte_in =0;
  uint16_t bit;


for(i=0;i<16;i++)
{
        //LE pin is low
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_9,GPIO_PIN_RESET);

for (bit = 0x8000; bit; bit >>= 1)
{

/* Shift-out a bit to the MOSI line */
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_4,(byte_out & bit) ? GPIO_PIN_SET : GPIO_PIN_RESET);


/* Delay for at least the peer's setup time */
for(int i=0;i<SPI_SCLK_LOW_TIME;i++)
{
}

/* Pull the clock line high */
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_5,GPIO_PIN_SET);


// /* Shift-in a bit from the MISO line */
// if(HAL_GPIO_ReadPin(GPIOC,GPIO_PIN_8)==1)
// byte_in |= bit;
//

/* Delay for at least the peer's hold time */
for(int i=0;i<SPI_SCLK_HIGH_TIME;i++)
{
}


/* Pull the clock line low */
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_5,GPIO_PIN_RESET);




}

        //LE pin is high
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_9,GPIO_PIN_SET);
HAL_Delay(1);

}



//return byte_in;

}

while (1)
{
    SPI_1(0xffff);
}

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf