This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BOOST-LP5569EVM: LP5569EVM GUI Compatibility Issue with MSP-EXP432E401Y – Firmware Support Request

Part Number: BOOST-LP5569EVM
Other Parts Discussed in Thread: MSP-EXP432E401Y, MSP432E401Y, LP5569

Tool/software:

Dear Texas Instruments Support Team,

I am currently evaluating the LP5569EVM using the official LP5569EVM GUI software.
The installation and hardware connection of the GUI program were completed successfully.

However, I am experiencing repeated issues when using the GUI with the MSP-EXP432E401Y LaunchPad connected to the LP5569EVM board. The following error messages appear upon launching the GUI:

- "Please update firmware"
- "Firmware is not valid for this product"

Actions I have taken:
1. Successfully installed and launched the LP5569EVM GUI software
2. Flashed a custom `.txt` firmware to the MSP432 using DSLite
3. Attempted to flash the `msp432fw.out` file included in the GUI installation folder
4. Verified the I²C connection between MSP432E401Y and the LP5569EVM (SDA, SCL, EN lines)

Despite these efforts, the GUI continues to display an invalid firmware error.

I would appreciate your support on the following:
1. Is the LP5569EVM GUI compatible with the MSP-EXP432E401Y LaunchPad?
2. If so, could you provide the correct firmware (`.out` or `.txt`) compatible with this configuration?
3. Alternatively, could you share a guideline or specification for building firmware that the GUI can recognize?

The hardware connection appears to be functioning correctly, but I am unable to proceed with evaluation due to firmware validation issues in the GUI.

Thank you very much for your assistance.

[Name] INJUN CHO
[Company] SENA in Republic of Korea 
[Email Address] injun.cho@sena.com

  • Hi Injun,

    The reason is because the LP5569EVM GUI is only compatible with the MSP-EXP432P401R launchPad, however, which is already EOLed (obsoleted and no longer supported).

    I think the workaround is that we can still use the use MSP-EXP432E401Y LaunchPad you have but through writing the firmware to communicate with the LP5569EVM without using the GUI.

    So could you tell me your initial requirement? like turn on the led and make the led work in animation mode? what's the animation pattern you want? then i can prepare the codes based on the MSP-EXP432E401Y LaunchPad, which you can directly copy and test.

    Best regards,

    Felix

  • Hello Felix Wang,

    Thank you very much for your quick response.

    Our company previously used a different LED driver, but since it has been discontinued, we’ve decided to use the LP5569 to utilize the inventory we currently have in stock.

    We are trying to replicate the exact same patterns from the previous LED driver, but we are having some difficulty implementing them with the LP5569.

    We need a total of 3 modes, and all patterns use only the red color.


    * Breathing Pattern Requirements
    1. ON (Fade In)
    - Brightness: 0 → 255 (Min to Max)
    - Step size: 1 per step
    - Step delay: 1.5ms per step
    - Total time: 255 * 1.5ms ≈ 382.5ms
    - At max brightness: wait 1 second

    2. OFF (Fade Out)
    - Brightness: 255 → 0 (Max to Min)
    - Step size: 1 per step
    - Step delay: 1.0ms per step
    - Total time: 255 * 1.0ms = 255ms
    - At min brightness: wait 2 seconds
    Repeat


    * Double Flash Pattern Requirements
    - 64ms ON
    - 64ms OFF
    - 64ms ON
    - 64ms OFF
    - 1.8s delay
    Repeat


    * Fast Flash Pattern Requirements
    - 64ms ON
    - 64ms OFF
    Repeat


    Ah, also — in our existing code, there's a table defined, but we’re not sure what it actually represents.

    Could you help explain the meaning of this table?
    We've looked through the documentation, but we just can't figure out how these values correspond to any pattern.


    uint8_t table_32[] = {
    0x50, 0x01, 0xB6,
    0x9F, 0x80,
    0x40, 0x00,
    0x21, 0xff,
    0x26, 0xff,
    0x5A, 0x00,
    0x00, 0x00,

    0x9F, 0x80,
    0x40, 0x00,
    0x06, 0x64,
    0x03, 0x64,
    0x5A, 0x00,
    0x00, 0x00,

    0x00, 0x00,
    0x00, 0x00, 0x00, 0x00
    };

    Thanks!

  • Hi Injun,

    Ok, I will try to provide the sample code and translate the arrays to you in next week.

    Besides that, i suggest you to take a look at the latest LED driver with pattern engine control, LP5812 (without boost) and LP5813 (has boost), which are more direct and easy to configure/control.

    Best regards,

    Felix

  • Hi Injun,

    Is it possible to provide the sample code based on the MSPM0L1306 Launch Pad? As MSP-EXP432E401Y Launch Pad is not available on my hand.

    As for the table, please find the notes below. However, I'm not sure why there is an additional byte - the 1st byte 0x50. Could you share the codes that take this table as input?

    I also attached the source file "example_test.src", which you can open it through the "Source Edit" panel on the Control page of the GUI.

    example_test.src

    Best regards,

    Felix

  • Hello, Felix Wang,

    Thank you so much for your detailed response.

    I’d like to share the code I received.

    The pattern I initially asked about corresponds to the following in the code:

    • Breathing Pattern Requirements = LED_TAILLIGHT_BREATHING

    • Double Flash Pattern Requirements = LED_TAILLIGHT_BURST_FLASH

    • The Fast Flash Pattern Requirements are for a new pattern that I need.

    I want to use new tables that apply these patterns and run them in the existing code.

    lp5569_reg.c
    /*
     ******************************************************************************
     * @file    lp5569_reg.c
     * @author  MEMS Software Solution Team
     * @brief   SI47XX driver file
     ******************************************************************************
     * @attention
     *
     * <h2><center>&copy; COPYRIGHT(c) 2018 STMicroelectronics</center></h2>
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *   1. Redistributions of source code must retain the above copyright notice,
     *      this list of conditions and the following disclaimer.
     *   2. Redistributions in binary form must reproduce the above copyright
     *      notice, this list of conditions and the following disclaimer in the
     *      documentation and/or other materials provided with the distribution.
     *   3. Neither the name of STMicroelectronics nor the names of its
     *      contributors may be used to endorse or promote products derived from
     *      this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     * POSSIBILITY OF SUCH DAMAGE.
     *
     */
    #include "FreeRTOS.h"
    #include "task.h"
    
    #include "string.h"
    #include "hal_log.h"
    
    #include "bsp_customer_config.h"
    
    #include "lp5569_reg.h"
    #include "bsp_led_taillight.h"
    
    #define BSP_LP5569_TYPE "LP5569"
    
    static lp5569_ctx_t g_dev_ctx;
    static LED_Taillight_type_t g_led_taillight_status;
    static void led_driver_init(void);
    
    int32_t lp5569_read_reg(uint8_t reg, uint8_t *data, uint16_t len)
    {
        return g_dev_ctx.read_reg(g_dev_ctx.handle, reg, data, len);
    }
    
    int32_t lp5569_write_reg(uint8_t *data, uint16_t len)
    {
        return g_dev_ctx.write_reg(g_dev_ctx.handle, data, len);
    }
    
    bool lp5569_init(lp5569_write_ptr write_reg, lp5569_read_ptr read_reg, void* handle)
    {
        bsp_led_taillight_t *led_taillight = (bsp_led_taillight_t*)handle;
    
        if ((write_reg == NULL) || (read_reg == NULL) || (handle == NULL)) {
            log_hal_msgid_info("[lp5569_init] init error\r\n", 0);
            return false;
        }
    
        g_dev_ctx.write_reg = (lp5569_write_ptr)write_reg;
        g_dev_ctx.read_reg  = (lp5569_read_ptr)read_reg;
        g_dev_ctx.handle    = handle;
    	
    	led_taillight->i2c_addr = LP5569_ADDRESS;
    
    	log_hal_msgid_info("slave addr %d check done\r\n", 1, led_taillight->i2c_addr);
    	return true;
    }
    
    const char* lp5569_get_type(void)
    {
        return BSP_LP5569_TYPE;
    }
    
    static void led_driver_init(void)
    {
    	uint8_t tx[2] = {0x00, 0x00};
    	int32_t ack = 0;
    	g_led_taillight_status = LED_TAILLIGHT_OFF;
    
    	LED_TAILLIGHT_EN_HIGH();
    	
    	vTaskDelay(20 / portTICK_RATE_MS);
    
    //	uint16 i = 0;
    //	/*32 * 16*/ /*s6.src*/
    //	const uint8 table_32[] = {0x01, 0xB6, 0x9F, 0x80, 0x40, 0x00, 0x32, 0x32, 0x07, 0xFF, 0x66, 0x00, 0x00, 0x00, 0x9F, 0x80,
    //						0x40, 0x00, 0x0A, 0xFF, 0x07, 0xFF, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    //						
    //	const uint8 table_32[] = {0x01, 0xB6, 0x9F, 0x80, 0x40, 0x00, 0x32, 0x32, 0x07, 0xFF, 0x66, 0x00, 0x00, 0x00, 0x9F, 0x80,
    //						0x40, 0x00, 0x0A, 0xFF, 0x07, 0xFF, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    //
    //
    //	/*s7_a.src left led*/
    //	const uint8 table_32[] = {0x00, 0x92, 0x9F, 0x80, 0x40, 0x00, 0x20, 0x32, 0x03, 0xFF, 0x5A, 0x00, 0x00, 0x00, 0x9F, 0x80,
    //							  0x40, 0x00, 0x06, 0xFF, 0x03, 0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    //	
    //	/*s7_a.src right led*/
    //	const uint8 table_32[] = {0x01, 0x24, 0x9F, 0x80, 0x40, 0x00, 0x20, 0x32, 0x03, 0xFF, 0x5A, 0x00, 0x00, 0x00, 0x9F, 0x80,
    //							  0x40, 0x00, 0x06, 0xFF, 0x03, 0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};						  
    
    	/*s7.src*/
    	uint8_t table_32[] = {0x50, 0x01, 0xB6, 0x9F, 0x80, 0x40, 0x00, 0x20, 0x32, 0x03, 0xFF, 0x5A, 0x00, 0x00, 0x00, 0x9F, 0x80,
    						  0x40, 0x00, 0x06, 0xFF, 0x03, 0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    
    	/*chip disable*/
    	tx[0] = 0x00;	tx[1] = 0x00;
    	ack = lp5569_write_reg(tx, 2);
        
    	/*chip enable*/
    	tx[0] = 0x00;	tx[1] = 0x40;
    	ack = lp5569_write_reg(tx, 2);
    
    	/*MISC Register*/
    //	tx[0] = 0x2F;	tx[1] = 0x48;	/*address auto disable*/
    	tx[0] = 0x2F;	tx[1] = 0x70;	/*address auto enable*/
    	ack = lp5569_write_reg(tx, 2);
    	
    	/*control*/
    	tx[0] = 0x02;	tx[1] = 0x54;	// 1CH, 2CH, 3CH Load Program to SRAM
    	ack = lp5569_write_reg(tx, 2);
         
    	/*Engine Program Starting Address*/
    	tx[0] = 0x4B;	tx[1] = 0x01;	// ENGINE1_PROG_START Register
    	ack = lp5569_write_reg(tx, 2);
        
       	tx[0] = 0x4C;	tx[1] = 0x07;	// ENGINE2_PROG_START Register
    	ack = lp5569_write_reg(tx, 2);
    
       	tx[0] = 0x4D;	tx[1] = 0x0D;	// ENGINE3_PROG_START Register
    	ack = lp5569_write_reg(tx, 2);
    
    	tx[0] = 0x4F;	tx[1] = 0x00;	// ENGINE4_PROG_START Register
    	ack = lp5569_write_reg(tx, 2);
    
    	/*load data*/
      	ack = lp5569_write_reg(table_32, 33);
    
    	/*chip disable*/
    	tx[0] = 0x00;	tx[1] = 0x00;
    	ack = lp5569_write_reg(tx, 2);
    }
    
    static void led_driver_deinit(void) {
    	vTaskDelay(20 / portTICK_RATE_MS);
    	
    	LED_TAILLIGHT_EN_LOW();
    }
    
    LED_Taillight_type_t lp5569_led_driver_get_mode(void)
    {
    	return g_led_taillight_status;
    }
    
    void lp5569_led_driver_set_mode(LED_Taillight_type_t mode)
    {
    	uint8_t tx[2] = {0x00, 0x00};
    	int32_t ack = 0;
    	uint16_t i = 0;
    	led_driver_init();
    
    	switch(mode)
    	{
    		/*LED Off*/
    		case LED_TAILLIGHT_OFF:
    			/*chip disable*/
    			tx[0] = 0x00;	tx[1] = 0x00;
    			ack = lp5569_write_reg(tx, 2);
    
    			led_driver_deinit();
    			g_led_taillight_status = LED_TAILLIGHT_OFF;
    			break;
    		case LED_TAILLIGHT_NIGHT_SOLID:
    			/*Night Solid*/
    			/*chip disable*/
    			tx[0] = 0x00;	tx[1] = 0x00;
    			ack = lp5569_write_reg(tx, 2);
    		    
    			/*chip enable*/
    			tx[0] = 0x00;	tx[1] = 0x40;
    			ack = lp5569_write_reg(tx, 2);
    
    //			tx[0] = 0x01;	tx[1] = 0xA8;	// Free Run
    			tx[0] = 0x01;	tx[1] = 0x00;	// Execution: Hold
    			ack = lp5569_write_reg(tx, 2);
    			
    			/*MISC Register*/
    			tx[0] = 0x2F;	tx[1] = 0x48;
    			ack = lp5569_write_reg(tx, 2);
    		    
    			/*control*/
    			tx[0] = 0x02;	tx[1] = 0x54;	// 1CH, 2CH, 3CH Load Program to SRAM
    			ack = lp5569_write_reg(tx, 2);
    		  
    			/*LED0_PWM ~ LED8_PWM*/
    			for(i=0;i<9;i++)
    			{
    				tx[0] = 0x16 + i;
    				tx[1] = 80;					// 80 = 31% duty cycle	// 80h = 50% duty cycle
    				ack = lp5569_write_reg(tx, 2);
    			}
    
    			g_led_taillight_status = LED_TAILLIGHT_NIGHT_SOLID;
    			break;
    		case LED_TAILLIGHT_NIGHT_FLASH:
    			/*Night Flash*/
    			/*chip disable*/
    			tx[0] = 0x00;	tx[1] = 0x00;
    			ack = lp5569_write_reg(tx, 2);
    		    
    			/*chip enable*/
    			tx[0] = 0x00;	tx[1] = 0x40;
    			ack = lp5569_write_reg(tx, 2);
    
    			/*MISC Register*/
    			tx[0] = 0x2F;	tx[1] = 0x49;	// Address auto-increment is enabled, 
    											// Charge-pump mode selection 1× mode
    											// Internal 32-kHz oscillator is enabled
    			ack = lp5569_write_reg(tx, 2);
    
    			/*control*/
    			tx[0] = 0x02;	tx[1] = 0x80;	// 1CH Free Run
    			ack = lp5569_write_reg(tx, 2);
    
    			tx[0] = 0x01;	tx[1] = 0x80;	// 1CH Run Program
    			ack = lp5569_write_reg(tx, 2);
    
    			g_led_taillight_status = LED_TAILLIGHT_NIGHT_FLASH;
    			break;
    		case LED_TAILLIGHT_DAY_FLASH:
    			/*Day Flash*/
    			/*chip disable*/
    			tx[0] = 0x00;	tx[1] = 0x00;
    			ack = lp5569_write_reg(tx, 2);
    		    
    			/*chip enable*/
    			tx[0] = 0x00;	tx[1] = 0x40;
    			ack = lp5569_write_reg(tx, 2);
    			
    			/*MISC Register*/
    			tx[0] = 0x2F;	tx[1] = 0x49;	// Address auto-increment is enabled, 
    											// Charge-pump mode selection 1× mode
    											// Internal 32-kHz oscillator is enabled
    			ack = lp5569_write_reg(tx, 2);
    			
    			/*control*/
    			tx[0] = 0x02;	tx[1] = 0x20;	// 2CH Free Run
    			ack = lp5569_write_reg(tx, 2);	
    			
    			tx[0] = 0x01;	tx[1] = 0x20;	// 2CH Run Program
    			ack = lp5569_write_reg(tx, 2);
    
    			g_led_taillight_status = LED_TAILLIGHT_DAY_FLASH;
    			break;
    		case LED_TAILLIGHT_BREATHING:
    			/*Night Flash*/
    			/*chip disable*/
    			tx[0] = 0x00;	tx[1] = 0x00;
    			ack = lp5569_write_reg(tx, 2);
    		    
    			/*chip enable*/
    			tx[0] = 0x00;	tx[1] = 0x40;
    			ack = lp5569_write_reg(tx, 2);
    
    			/*MISC Register*/
    			tx[0] = 0x2F;	tx[1] = 0x49;	// Address auto-increment is enabled, 
    											// Charge-pump mode selection 1× mode
    											// Internal 32-kHz oscillator is enabled
    			ack = lp5569_write_reg(tx, 2);
    
    			/*control*/
    			tx[0] = 0x02;	tx[1] = 0x80;	// 1CH Free Run
    			ack = lp5569_write_reg(tx, 2);
    
    			tx[0] = 0x01;	tx[1] = 0x80;	// 1CH Run Program
    			ack = lp5569_write_reg(tx, 2);		
    			g_led_taillight_status = LED_TAILLIGHT_BREATHING;
    			break;
    		
    		case LED_TAILLIGHT_BURST_FLASH:
    			/*Day Flash*/
    			/*chip disable*/
    			tx[0] = 0x00;	tx[1] = 0x00;
    			ack = lp5569_write_reg(tx, 2);
    		    
    			/*chip enable*/
    			tx[0] = 0x00;	tx[1] = 0x40;
    			ack = lp5569_write_reg(tx, 2);
    			
    			/*MISC Register*/
    			tx[0] = 0x2F;	tx[1] = 0x49;	// Address auto-increment is enabled, 
    											// Charge-pump mode selection 1× mode
    											// Internal 32-kHz oscillator is enabled
    			ack = lp5569_write_reg(tx, 2);
    			
    			/*control*/
    			tx[0] = 0x02;	tx[1] = 0x20;	// 2CH Free Run
    			ack = lp5569_write_reg(tx, 2);	
    			
    			tx[0] = 0x01;	tx[1] = 0x20;	// 2CH Run Program
    			ack = lp5569_write_reg(tx, 2);		
    			g_led_taillight_status = LED_TAILLIGHT_BURST_FLASH;
    			break;
    		default:
    			break;
    	}
    }
    
    LED_Taillight_type_t lp5569_led_driver_change_mode(void)
    {
    	if(lp5569_led_driver_get_mode() == LED_TAILLIGHT_OFF)
    	{
    		lp5569_led_driver_set_mode(LED_TAILLIGHT_NIGHT_SOLID);
    		return LED_TAILLIGHT_NIGHT_SOLID;
    	}
    	else if(lp5569_led_driver_get_mode() == LED_TAILLIGHT_NIGHT_SOLID)
    	{
    		lp5569_led_driver_set_mode(LED_TAILLIGHT_NIGHT_FLASH);
    		return LED_TAILLIGHT_NIGHT_FLASH;
    	}
    	else if(lp5569_led_driver_get_mode() == LED_TAILLIGHT_NIGHT_FLASH)
    	{
    		lp5569_led_driver_set_mode(LED_TAILLIGHT_DAY_FLASH);
    		return LED_TAILLIGHT_DAY_FLASH;
    	}
    	else if(lp5569_led_driver_get_mode() >= LED_TAILLIGHT_DAY_FLASH)
    	{
    		lp5569_led_driver_set_mode(LED_TAILLIGHT_OFF);
    		return LED_TAILLIGHT_OFF;
    	}
    
    	lp5569_led_driver_set_mode(LED_TAILLIGHT_OFF);
    	return LED_TAILLIGHT_OFF;
    }
    
    bsp_led_function_t lp5569_led_func = {
    	lp5569_led_driver_get_mode, 
    	lp5569_led_driver_set_mode, 
    	lp5569_led_driver_change_mode,
    };
    
    /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
    

  • Hi Injun,

    ok, I will update the code and send it back to you in this week.

    Best regards,

    Felix

  • Hi Injun,

    Attached the updated code. Please have a check.

    There are 3 parts modified. As for the added case "LED_TAILLIGHT_FAST_FLASH", you need to add the definition for this variable.

    2055.lp5569_reg.c
    /*
     ******************************************************************************
     * @file    lp5569_reg.c
     * @author  MEMS Software Solution Team
     * @brief   SI47XX driver file
     ******************************************************************************
     * @attention
     *
     * <h2><center>&copy; COPYRIGHT(c) 2018 STMicroelectronics</center></h2>
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *   1. Redistributions of source code must retain the above copyright notice,
     *      this list of conditions and the following disclaimer.
     *   2. Redistributions in binary form must reproduce the above copyright
     *      notice, this list of conditions and the following disclaimer in the
     *      documentation and/or other materials provided with the distribution.
     *   3. Neither the name of STMicroelectronics nor the names of its
     *      contributors may be used to endorse or promote products derived from
     *      this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     * POSSIBILITY OF SUCH DAMAGE.
     *
     */
    #include "FreeRTOS.h"
    #include "task.h"
    
    #include "string.h"
    #include "hal_log.h"
    
    #include "bsp_customer_config.h"
    
    #include "lp5569_reg.h"
    #include "bsp_led_taillight.h"
    
    #define BSP_LP5569_TYPE "LP5569"
    
    static lp5569_ctx_t g_dev_ctx;
    static LED_Taillight_type_t g_led_taillight_status;
    static void led_driver_init(void);
    
    int32_t lp5569_read_reg(uint8_t reg, uint8_t *data, uint16_t len)
    {
        return g_dev_ctx.read_reg(g_dev_ctx.handle, reg, data, len);
    }
    
    int32_t lp5569_write_reg(uint8_t *data, uint16_t len)
    {
        return g_dev_ctx.write_reg(g_dev_ctx.handle, data, len);
    }
    
    bool lp5569_init(lp5569_write_ptr write_reg, lp5569_read_ptr read_reg, void* handle)
    {
        bsp_led_taillight_t *led_taillight = (bsp_led_taillight_t*)handle;
    
        if ((write_reg == NULL) || (read_reg == NULL) || (handle == NULL)) {
            log_hal_msgid_info("[lp5569_init] init error\r\n", 0);
            return false;
        }
    
        g_dev_ctx.write_reg = (lp5569_write_ptr)write_reg;
        g_dev_ctx.read_reg  = (lp5569_read_ptr)read_reg;
        g_dev_ctx.handle    = handle;
    	
    	led_taillight->i2c_addr = LP5569_ADDRESS;
    
    	log_hal_msgid_info("slave addr %d check done\r\n", 1, led_taillight->i2c_addr);
    	return true;
    }
    
    const char* lp5569_get_type(void)
    {
        return BSP_LP5569_TYPE;
    }
    
    static void led_driver_init(void)
    {
    	uint8_t tx[2] = {0x00, 0x00};
    	int32_t ack = 0;
    	g_led_taillight_status = LED_TAILLIGHT_OFF;
    
    	LED_TAILLIGHT_EN_HIGH();
    	
    	vTaskDelay(20 / portTICK_RATE_MS);
    
    //	uint16 i = 0;
    //	/*32 * 16*/ /*s6.src*/
    //	const uint8 table_32[] = {0x01, 0xB6, 0x9F, 0x80, 0x40, 0x00, 0x32, 0x32, 0x07, 0xFF, 0x66, 0x00, 0x00, 0x00, 0x9F, 0x80,
    //						0x40, 0x00, 0x0A, 0xFF, 0x07, 0xFF, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    //						
    //	const uint8 table_32[] = {0x01, 0xB6, 0x9F, 0x80, 0x40, 0x00, 0x32, 0x32, 0x07, 0xFF, 0x66, 0x00, 0x00, 0x00, 0x9F, 0x80,
    //						0x40, 0x00, 0x0A, 0xFF, 0x07, 0xFF, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    //
    //
    //	/*s7_a.src left led*/
    //	const uint8 table_32[] = {0x00, 0x92, 0x9F, 0x80, 0x40, 0x00, 0x20, 0x32, 0x03, 0xFF, 0x5A, 0x00, 0x00, 0x00, 0x9F, 0x80,
    //							  0x40, 0x00, 0x06, 0xFF, 0x03, 0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    //	
    //	/*s7_a.src right led*/
    //	const uint8 table_32[] = {0x01, 0x24, 0x9F, 0x80, 0x40, 0x00, 0x20, 0x32, 0x03, 0xFF, 0x5A, 0x00, 0x00, 0x00, 0x9F, 0x80,
    //							  0x40, 0x00, 0x06, 0xFF, 0x03, 0xFF, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};						  
    
    	/*s7.src*/
    	uint8_t table_32[] = {0x50, /*memory start address*/
    							01, B6, 9F, 80, 40, 00, 06, FF, 74, 00, 74, 00, 5A, 00, 05, FF, 74, 00, 74, 00, 5A, 00, A0, 87, A0, 02, /* ENGIN 1 - breathing pattern*/
    							9F, 80, 40, FF, 48, 00, 40, 00, 48, 00, A0, 8D, 7A, 00, 7A, 00, A0, 92, A0, 0D, /* ENGIN 2 - double flash pattern */ 
    							9F, 80, 40, FF, 48, 00, 40, 00, 48, 00, A0, 17, /* ENGIN 3 - fast flash pattern*/
    							00, 00};
    
    	/*chip disable*/
    	tx[0] = 0x00;	tx[1] = 0x00;
    	ack = lp5569_write_reg(tx, 2);
        
    	/*chip enable*/
    	tx[0] = 0x00;	tx[1] = 0x40;
    	ack = lp5569_write_reg(tx, 2);
    
    	/*MISC Register*/
    //	tx[0] = 0x2F;	tx[1] = 0x48;	/*address auto disable*/
    	tx[0] = 0x2F;	tx[1] = 0x70;	/*address auto enable*/
    	ack = lp5569_write_reg(tx, 2);
    	
    	/*control*/
    	tx[0] = 0x02;	tx[1] = 0x54;	// 1CH, 2CH, 3CH Load Program to SRAM
    	ack = lp5569_write_reg(tx, 2);
         
    	/*Engine Program Starting Address*/
    	tx[0] = 0x4B;	tx[1] = 0x01;	// ENGINE1_PROG_START Register
    	ack = lp5569_write_reg(tx, 2);
        
       	tx[0] = 0x4C;	tx[1] = 0x0D;	// ENGINE2_PROG_START Register
    	ack = lp5569_write_reg(tx, 2);
    
       	tx[0] = 0x4D;	tx[1] = 0x17;	// ENGINE3_PROG_START Register
    	ack = lp5569_write_reg(tx, 2);
    
    	tx[0] = 0x4F;	tx[1] = 0x00;	// ENGINE4_PROG_START Register
    	ack = lp5569_write_reg(tx, 2);
    
    	/*load data*/
      	ack = lp5569_write_reg(table_32, 33);
    
    	/*chip disable*/
    	tx[0] = 0x00;	tx[1] = 0x00;
    	ack = lp5569_write_reg(tx, 2);
    }
    
    static void led_driver_deinit(void) {
    	vTaskDelay(20 / portTICK_RATE_MS);
    	
    	LED_TAILLIGHT_EN_LOW();
    }
    
    LED_Taillight_type_t lp5569_led_driver_get_mode(void)
    {
    	return g_led_taillight_status;
    }
    
    void lp5569_led_driver_set_mode(LED_Taillight_type_t mode)
    {
    	uint8_t tx[2] = {0x00, 0x00};
    	int32_t ack = 0;
    	uint16_t i = 0;
    	led_driver_init();
    
    	switch(mode)
    	{
    		/*LED Off*/
    		case LED_TAILLIGHT_OFF:
    			/*chip disable*/
    			tx[0] = 0x00;	tx[1] = 0x00;
    			ack = lp5569_write_reg(tx, 2);
    
    			led_driver_deinit();
    			g_led_taillight_status = LED_TAILLIGHT_OFF;
    			break;
    		case LED_TAILLIGHT_NIGHT_SOLID:
    			/*Night Solid*/
    			/*chip disable*/
    			tx[0] = 0x00;	tx[1] = 0x00;
    			ack = lp5569_write_reg(tx, 2);
    		    
    			/*chip enable*/
    			tx[0] = 0x00;	tx[1] = 0x40;
    			ack = lp5569_write_reg(tx, 2);
    
    //			tx[0] = 0x01;	tx[1] = 0xA8;	// Free Run
    			tx[0] = 0x01;	tx[1] = 0x00;	// Execution: Hold
    			ack = lp5569_write_reg(tx, 2);
    			
    			/*MISC Register*/
    			tx[0] = 0x2F;	tx[1] = 0x48;
    			ack = lp5569_write_reg(tx, 2);
    		    
    			/*control*/
    			tx[0] = 0x02;	tx[1] = 0x54;	// 1CH, 2CH, 3CH Load Program to SRAM
    			ack = lp5569_write_reg(tx, 2);
    		  
    			/*LED0_PWM ~ LED8_PWM*/
    			for(i=0;i<9;i++)
    			{
    				tx[0] = 0x16 + i;
    				tx[1] = 80;					// 80 = 31% duty cycle	// 80h = 50% duty cycle
    				ack = lp5569_write_reg(tx, 2);
    			}
    
    			g_led_taillight_status = LED_TAILLIGHT_NIGHT_SOLID;
    			break;
    		case LED_TAILLIGHT_NIGHT_FLASH:
    			/*Night Flash*/
    			/*chip disable*/
    			tx[0] = 0x00;	tx[1] = 0x00;
    			ack = lp5569_write_reg(tx, 2);
    		    
    			/*chip enable*/
    			tx[0] = 0x00;	tx[1] = 0x40;
    			ack = lp5569_write_reg(tx, 2);
    
    			/*MISC Register*/
    			tx[0] = 0x2F;	tx[1] = 0x49;	// Address auto-increment is enabled, 
    											// Charge-pump mode selection 1× mode
    											// Internal 32-kHz oscillator is enabled
    			ack = lp5569_write_reg(tx, 2);
    
    			/*control*/
    			tx[0] = 0x02;	tx[1] = 0x80;	// 1CH Free Run
    			ack = lp5569_write_reg(tx, 2);
    
    			tx[0] = 0x01;	tx[1] = 0x80;	// 1CH Run Program
    			ack = lp5569_write_reg(tx, 2);
    
    			g_led_taillight_status = LED_TAILLIGHT_NIGHT_FLASH;
    			break;
    		case LED_TAILLIGHT_DAY_FLASH:
    			/*Day Flash*/
    			/*chip disable*/
    			tx[0] = 0x00;	tx[1] = 0x00;
    			ack = lp5569_write_reg(tx, 2);
    		    
    			/*chip enable*/
    			tx[0] = 0x00;	tx[1] = 0x40;
    			ack = lp5569_write_reg(tx, 2);
    			
    			/*MISC Register*/
    			tx[0] = 0x2F;	tx[1] = 0x49;	// Address auto-increment is enabled, 
    											// Charge-pump mode selection 1× mode
    											// Internal 32-kHz oscillator is enabled
    			ack = lp5569_write_reg(tx, 2);
    			
    			/*control*/
    			tx[0] = 0x02;	tx[1] = 0x20;	// 2CH Free Run
    			ack = lp5569_write_reg(tx, 2);	
    			
    			tx[0] = 0x01;	tx[1] = 0x20;	// 2CH Run Program
    			ack = lp5569_write_reg(tx, 2);
    
    			g_led_taillight_status = LED_TAILLIGHT_DAY_FLASH;
    			break;
    		case LED_TAILLIGHT_BREATHING:
    			/*Night Flash*/
    			/*chip disable*/
    			tx[0] = 0x00;	tx[1] = 0x00;
    			ack = lp5569_write_reg(tx, 2);
    		    
    			/*chip enable*/
    			tx[0] = 0x00;	tx[1] = 0x40;
    			ack = lp5569_write_reg(tx, 2);
    
    			/*MISC Register*/
    			tx[0] = 0x2F;	tx[1] = 0x49;	// Address auto-increment is enabled, 
    											// Charge-pump mode selection 1× mode
    											// Internal 32-kHz oscillator is enabled
    			ack = lp5569_write_reg(tx, 2);
    
    			/*control*/
    			tx[0] = 0x02;	tx[1] = 0x80;	// 1CH Free Run
    			ack = lp5569_write_reg(tx, 2);
    
    			tx[0] = 0x01;	tx[1] = 0x80;	// 1CH Run Program
    			ack = lp5569_write_reg(tx, 2);		
    			g_led_taillight_status = LED_TAILLIGHT_BREATHING;
    			break;
    		
    		case LED_TAILLIGHT_BURST_FLASH:
    			/*Day Flash*/
    			/*chip disable*/
    			tx[0] = 0x00;	tx[1] = 0x00;
    			ack = lp5569_write_reg(tx, 2);
    		    
    			/*chip enable*/
    			tx[0] = 0x00;	tx[1] = 0x40;
    			ack = lp5569_write_reg(tx, 2);
    			
    			/*MISC Register*/
    			tx[0] = 0x2F;	tx[1] = 0x49;	// Address auto-increment is enabled, 
    											// Charge-pump mode selection 1× mode
    											// Internal 32-kHz oscillator is enabled
    			ack = lp5569_write_reg(tx, 2);
    			
    			/*control*/
    			tx[0] = 0x02;	tx[1] = 0x20;	// 2CH Free Run
    			ack = lp5569_write_reg(tx, 2);	
    			
    			tx[0] = 0x01;	tx[1] = 0x20;	// 2CH Run Program
    			ack = lp5569_write_reg(tx, 2);		
    			g_led_taillight_status = LED_TAILLIGHT_BURST_FLASH;
    			break;
    
    		case LED_TAILLIGHT_FAST_FLASH:
    			/*Day Flash*/
    			/*chip disable*/
    			tx[0] = 0x00;	tx[1] = 0x00;
    			ack = lp5569_write_reg(tx, 2);
    		    
    			/*chip enable*/
    			tx[0] = 0x00;	tx[1] = 0x40;
    			ack = lp5569_write_reg(tx, 2);
    			
    			/*MISC Register*/
    			tx[0] = 0x2F;	tx[1] = 0x49;	// Address auto-increment is enabled, 
    											// Charge-pump mode selection 1× mode
    											// Internal 32-kHz oscillator is enabled
    			ack = lp5569_write_reg(tx, 2);
    			
    			/*control*/
    			tx[0] = 0x02;	tx[1] = 0x08;	// 3CH Free Run
    			ack = lp5569_write_reg(tx, 2);	
    			
    			tx[0] = 0x01;	tx[1] = 0x08;	// 3CH Run Program
    			ack = lp5569_write_reg(tx, 2);		
    			g_led_taillight_status = LED_TAILLIGHT_FAST_FLASH;
    			break;	
    		default:
    			break;
    	}
    }
    
    LED_Taillight_type_t lp5569_led_driver_change_mode(void)
    {
    	if(lp5569_led_driver_get_mode() == LED_TAILLIGHT_OFF)
    	{
    		lp5569_led_driver_set_mode(LED_TAILLIGHT_NIGHT_SOLID);
    		return LED_TAILLIGHT_NIGHT_SOLID;
    	}
    	else if(lp5569_led_driver_get_mode() == LED_TAILLIGHT_NIGHT_SOLID)
    	{
    		lp5569_led_driver_set_mode(LED_TAILLIGHT_NIGHT_FLASH);
    		return LED_TAILLIGHT_NIGHT_FLASH;
    	}
    	else if(lp5569_led_driver_get_mode() == LED_TAILLIGHT_NIGHT_FLASH)
    	{
    		lp5569_led_driver_set_mode(LED_TAILLIGHT_DAY_FLASH);
    		return LED_TAILLIGHT_DAY_FLASH;
    	}
    	else if(lp5569_led_driver_get_mode() >= LED_TAILLIGHT_DAY_FLASH)
    	{
    		lp5569_led_driver_set_mode(LED_TAILLIGHT_OFF);
    		return LED_TAILLIGHT_OFF;
    	}
    
    	lp5569_led_driver_set_mode(LED_TAILLIGHT_OFF);
    	return LED_TAILLIGHT_OFF;
    }
    
    bsp_led_function_t lp5569_led_func = {
    	lp5569_led_driver_get_mode, 
    	lp5569_led_driver_set_mode, 
    	lp5569_led_driver_change_mode,
    };
    
    /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
    

    Best regards,

    Felix

  • Hello Felix Wang,
    Thank you so much — everything is working perfectly now thanks to you.
    Wishing you endless happiness!