Skip to content

Commit

Permalink
[Silabs] Adds SPI multiplex changes for rs911x (#26238)
Browse files Browse the repository at this point in the history
* SPI multiplex changes for rs911x

* Adds intermediate changes with cleanup

* Adds additional macro checks

* Adds updated working logic for multiplexing expansion header and LCD

* Adds missing ;

* Adds fix for WF200 baudrate on SPI

* Adds fix for third_party

* Adds updated log statements

* Adds fix for log statement

* Adds conditional use of semaphore

* Adds conditional EFR32MG24 semaphore logic

* Adds fix for err usage

* Refactor SPIDRV_ReInit

* Adds SPIDRV_ReInit for EUSART

* Added error logs

* Added logs

* Revert submodule update

* Aligned the macros

* Restyled

* Aligned the MACRO

* Adds cosmetic changes

* Removes debug log

* Adds sl_wfx_host_post_bootloader_spi_transfer in relevant failure outcomes

* Adds re factored local function updateDisplay(void)

* Removes spi_multiplex.c

* Removes development debug trace and log

* Renamed conflicting variable

* Adds comment for technical debt and understanding

* Adds changes for updateDisplay function

* Adds checks for semaphore used for sync peripherals

* Clean up of unreachable code due to portMAX_DELAY

* Adds fix for comment alignment

* Changes SPIDRV_ReInit to SPIDRV_SetBaudrate

* Removes unused error variable

* Clean up logs

* Clean up of logs

* Replace magic number

* Added tickets for tracking additional rework

* Clean up additional logs

* Adds fix for print statements

* Adds fix for MACRO

* Adds fix for MATTER-1904

* Adds partial fix for MATTER-1907

* Adds for fix code compilation

* Adds code to clean up MACROs

* Restyled by clang-format

* Removes debug log

* Adds fix for MATTER-1907

* Adds use of the ECODE_EMDRV_SPIDRV status instead of generic ECODE

* Adds comment for declaring the current supported family.

---------

Co-authored-by: shasaicha <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Jan 30, 2024
1 parent ab72cac commit 1237048
Show file tree
Hide file tree
Showing 11 changed files with 625 additions and 488 deletions.
41 changes: 18 additions & 23 deletions examples/platform/silabs/display/demo-ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "glib.h"
#include <stdio.h>
#include <string.h>
#if (defined(EFR32MG24) && defined(WF200_WIFI))
#if (defined(EFR32MG24) && defined(SL_WIFI))
#include "spi_multiplex.h"
#endif

Expand Down Expand Up @@ -92,7 +92,6 @@ static void demoUIDisplayLogo(void)
GLIB_drawBitmap(&glibContext, SILICONLABS_X_POSITION, SILICONLABS_Y_POSITION, SILICONLABS_BITMAP_WIDTH,
SILICONLABS_BITMAP_HEIGHT, siliconlabsBitmap);
}

/*******************************************************************************
************************** GLOBAL FUNCTIONS *******************************
******************************************************************************/
Expand All @@ -101,33 +100,35 @@ void demoUIInit(GLIB_Context_t * context)
memcpy(&glibContext, context, sizeof(GLIB_Context_t));
}

sl_status_t updateDisplay(void)
{
#if (defined(EFR32MG24) && defined(SL_WIFI))
sl_wfx_host_pre_lcd_spi_transfer();
#endif
sl_status_t status = DMD_updateDisplay();
#if (defined(EFR32MG24) && defined(SL_WIFI))
sl_wfx_host_post_lcd_spi_transfer();
#endif
if (status != DMD_OK)
return SL_STATUS_FAIL;
return SL_STATUS_OK;
}

void demoUIDisplayHeader(char * name)
{
demoUIDisplayLogo();
if (APP_NAME_MAX_LENGTH >= strlen(name))
{
GLIB_drawStringOnLine(&glibContext, name, 5, GLIB_ALIGN_CENTER, 0, 0, true);
}
#if (defined(EFR32MG24) && defined(WF200_WIFI))
pre_lcd_spi_transfer();
#endif
DMD_updateDisplay();
#if (defined(EFR32MG24) && defined(WF200_WIFI))
post_lcd_spi_transfer();
#endif
updateDisplay();
}

void demoUIDisplayApp(bool on)
{
GLIB_drawBitmap(&glibContext, APP_X_POSITION, APP_Y_POSITION, APP_BITMAP_WIDTH, APP_BITMAP_HEIGHT,
(on ? OnStateBitMap : OffStateBitMap));
#if (defined(EFR32MG24) && defined(WF200_WIFI))
pre_lcd_spi_transfer();
#endif
DMD_updateDisplay();
#if (defined(EFR32MG24) && defined(WF200_WIFI))
post_lcd_spi_transfer();
#endif
updateDisplay();
}

void demoUIDisplayProtocol(demoUIProtocol protocol, bool isConnected)
Expand All @@ -138,13 +139,7 @@ void demoUIDisplayProtocol(demoUIProtocol protocol, bool isConnected)
(protocol == DEMO_UI_PROTOCOL1 ? PROT1_BITMAP_HEIGHT : PROT2_BITMAP_HEIGHT),
(protocol == DEMO_UI_PROTOCOL1 ? (isConnected ? PROT1_BITMAP_CONN : PROT1_BITMAP)
: (isConnected ? PROT2_BITMAP_CONN : PROT2_BITMAP)));
#if (defined(EFR32MG24) && defined(WF200_WIFI))
pre_lcd_spi_transfer();
#endif
DMD_updateDisplay();
#if (defined(EFR32MG24) && defined(WF200_WIFI))
post_lcd_spi_transfer();
#endif
updateDisplay();
}

void demoUIClearMainScreen(uint8_t * name)
Expand Down
172 changes: 95 additions & 77 deletions examples/platform/silabs/display/demo-ui.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
/***************************************************************************/ /**
* @file
* @brief User Interface for demo.
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc.
*www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon
*Laboratories Inc. Your use of this software is
*governed by the terms of Silicon Labs Master
*Software License Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement.
*This software is distributed to you in Source Code
*format and is governed by the sections of the MSLA
*applicable to Source Code.
*
******************************************************************************/
/***************************************************************************/
/**
* @file
* @brief User Interface for demo.
*******************************************************************************
* # License
* <b>Copyright 2020 Silicon Laboratories Inc.
*www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon
*Laboratories Inc. Your use of this software is
*governed by the terms of Silicon Labs Master
*Software License Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement.
*This software is distributed to you in Source Code
*format and is governed by the sections of the MSLA
*applicable to Source Code.
*
******************************************************************************/

#pragma once

Expand All @@ -25,13 +26,15 @@ extern "C" {
#endif

#include "glib.h"
/**************************************************************************/ /**
* DEMO UI uses the underlying DMD interface and the
*GLIB and exposes several wrapper functions to
*application. These functions are used to display
* different bitmaps for the demo.
*
******************************************************************************/
#include "sl_status.h"
/**************************************************************************/
/**
* DEMO UI uses the underlying DMD interface and the
*GLIB and exposes several wrapper functions to
*application. These functions are used to display
* different bitmaps for the demo.
*
******************************************************************************/

#define APP_NAME_MAX_LENGTH 20

Expand Down Expand Up @@ -73,67 +76,82 @@ typedef enum
****************************** PROTOTYPES *********************************
******************************************************************************/

/**************************************************************************/ /**
* @brief
* Initilize the GLIB and DMD interfaces.
*
* @param[in] void
*
* @return
* void
*****************************************************************************/
/**************************************************************************/
/**
* @brief
* Initilize the GLIB and DMD interfaces.
*
* @param[in] void
*
* @return
* void
*****************************************************************************/
void demoUIInit(GLIB_Context_t * context);

/**************************************************************************/ /**
* @brief
* Update the display with Silicon Labs logo and
*application name.
*
* @param[in] name name of the current application.
*
* @return
* void
*****************************************************************************/
/**************************************************************************/
/**
* @brief
* Update the display with Silicon Labs logo and
*application name.
*
* @param[in] name name of the current application.
*
* @return
* void
*****************************************************************************/
void demoUIDisplayHeader(char * name);

/**************************************************************************/ /**
* @brief
* Update the display with App image. Bool state only
*for now.
*
* @param[in] on status of App
*
* @return
* void
*****************************************************************************/
/**************************************************************************/
/**
* @brief
* Update the display with App image. Bool state only
*for now.
*
* @param[in] on status of App
*
* @return
* void
*****************************************************************************/
void demoUIDisplayApp(bool on);

/**************************************************************************/ /**
* @brief
* Update the display to show if the bluetooth is
*connected to the mobile device.
*
* @param[in] bool, true if the Light is connected to
*mobile device, false otherwise.
*
* @return
* void
*****************************************************************************/
/**************************************************************************/
/**
* @brief
* Update the display to show if the bluetooth is
*connected to the mobile device.
*
* @param[in] bool, true if the Light is connected to
*mobile device, false otherwise.
*
* @return
* void
*****************************************************************************/
void demoUIDisplayProtocol(demoUIProtocol protocol, bool isConnected);

/**************************************************************************/ /**
* @brief
* Clear the Lcd screen and display the main screen.
*
* @param[in] name - application name
* @param[in] showPROT1 - show protocol 1 related icon.
* @param[in] showPROT2 - show protocol 2 related icon.
*
* @return
* void
*****************************************************************************/
/**************************************************************************/
/**
* @brief
* Clear the Lcd screen and display the main screen.
*
* @param[in] name - application name
* @param[in] showPROT1 - show protocol 1 related icon.
* @param[in] showPROT2 - show protocol 2 related icon.
*
* @return
* void
*****************************************************************************/
void demoUIClearMainScreen(uint8_t * name);

/**************************************************************************/
/**
* @brief
* Clear the Lcd screen and display the main screen.
*
* @return
* Returns SL_STATUS_OK if successful, error otherwise.
*****************************************************************************/
sl_status_t updateDisplay(void);

#ifdef __cplusplus
}
#endif
24 changes: 3 additions & 21 deletions examples/platform/silabs/display/lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

#include "sl_board_control.h"

#if (defined(EFR32MG24) && defined(WF200_WIFI))
#if (defined(EFR32MG24) && defined(SL_WIFI))
#include "spi_multiplex.h"
#endif
#define LCD_SIZE 128
Expand Down Expand Up @@ -120,18 +120,7 @@ int SilabsLCD::DrawPixel(void * pContext, int32_t x, int32_t y)

int SilabsLCD::Update(void)
{
int status;
#if (defined(EFR32MG24) && defined(WF200_WIFI))
pre_lcd_spi_transfer();
#endif
status = DMD_updateDisplay();
#if (defined(EFR32MG24) && defined(WF200_WIFI))
post_lcd_spi_transfer();
#endif
/*
* TO-DO; Above logic can be optimised by writing a common API
*/
return status;
return updateDisplay();
}

void SilabsLCD::WriteDemoUI(bool state)
Expand Down Expand Up @@ -194,14 +183,7 @@ void SilabsLCD::WriteQRCode()
}
}
}
#if (defined(EFR32MG24) && defined(WF200_WIFI))
pre_lcd_spi_transfer();
#endif

DMD_updateDisplay();
#if (defined(EFR32MG24) && defined(WF200_WIFI))
post_lcd_spi_transfer();
#endif
SilabsLCD::Update();
}

void SilabsLCD::SetQRCode(uint8_t * str, uint32_t size)
Expand Down
Loading

0 comments on commit 1237048

Please sign in to comment.