Skip navigation
Home > All Places > WICED Studio Wi-Fi/Combo > WICED Studio Wi-Fi/Combo Forums > Blog > 2014 > December

Here is a patch for ThreadX for WICED SDK-3.1.x version.


The following is the patch for .../WICED/RTOS/ThreadX/WWD/wwd_rtos.c:


@@ -84,7 +84,7 @@ wwd_result_t host_rtos_create_thread_with_arg( /*@out@*/ host_thread_type_t* thr
     tx_thread_stack_error_notify( wiced_threadx_stack_error_handler );
#endif /* ifdef DEBUG */

-    status = tx_thread_create( thread, (char*) name, (void(*)( ULONG )) entry_function, arg, stack, (ULONG) stack_size, (UINT) priority, 0, TX_NO_TIME_SLICE, (UINT) TX_AUTO_START );
+    status = tx_thread_create( thread, (char*) name, (void(*)( ULONG )) entry_function, arg, stack, (ULONG) stack_size, (UINT) priority, (UINT) priority, TX_NO_TIME_SLICE, (UINT) TX_AUTO_START );

@@ -266,7 +266,7 @@ wwd_result_t host_rtos_delay_milliseconds( uint32_t num_ms )
         uint32_t time_reference = host_platform_get_cycle_count( );
-        int32_t wait_time       = (int32_t)num_ms * CPU_CLOCK_HZ / 1000;
+        int32_t wait_time       = (int32_t)num_ms * (int32_t)CPU_CLOCK_HZ / 1000;
         while ( wait_time > 0 )
             uint32_t current_time = host_platform_get_cycle_count( );


The .../WICED/RTOS/ThreadX/WWD/wwd_rtos.c source file is also attached.

This application snippet demonstrates the I2C device interface using WICED SDK-3.x.


The sample application sets up the I2C device interface and send commands to the I2C device then receives replies, if any, from the I2C device.


For this example "BlinkM - I2C Controlled RGB LED" ( I2C device is used to test the code. It could be any other I2C device chosen for your platform as well.


For BCM943362WCD4 evaluation platform update the platform.c and platform.h files for I2C device.


Update the .../platforms/BCM943362WCD4/platform.c file by adding the following changes to the file:

const platform_i2c_t platform_i2c_peripherals[] =
    [WICED_I2C_1] =
        .port                    = I2C1,
        .pin_scl                 = &platform_gpio_pins[WICED_GPIO_11],
        .pin_sda                 = &platform_gpio_pins[WICED_GPIO_12],
        .peripheral_clock_reg    = RCC_APB1Periph_I2C1,
        .tx_dma                  = DMA1,
        .tx_dma_peripheral_clock = RCC_AHB1Periph_DMA1,
        .tx_dma_stream           = DMA1_Stream7,
        .rx_dma_stream           = DMA1_Stream0,
        .tx_dma_stream_id        = 7,
        .rx_dma_stream_id        = 0,
        .tx_dma_channel          = DMA_Channel_1,
        .rx_dma_channel          = DMA_Channel_1,
        .gpio_af                 = GPIO_AF_I2C1


For platforms/BCM943362WCD4/platform.h file add the WICED_I2C_1 to the wiced_i2c_t as below:

typedef enum
} wiced_i2c_t;


The platform files for BCM943362WCD4 are attached.


For BCM943341WCD1 I2C device of WICED_I2C_1 is already defined in the platform files. For completeness the platform files are attached. The I2C device of WICED_I2C_1 for BCM943362WCD1 is already defined in the platform files. For completeness the platform files are attached.



Your application specific platform files can be updated as above to interface the chosen I2C device to the WICED SDK 3.x platform.


1. To run the test, connect the I2C device to the evaluation board as following:


Connection setup for I2C device to STM32F4xx based WICED evaluation board

I2C-Device   BCM943341WCD1 J7 Header

      -                    J7-27

     +                    J7-28

     SDA               J7-26

     SCL               J7-25


Connection setup for I2C device to STM32F2xx based WICED evaluation board

I2C-Device   BCM943362WCD4 J7 Header

     -                         J7-2

     +                        J7-1

     SDA                   J7-7

     SCL                   J7-6


2. Unzip and copy the attached files to the WICED SDK-3.x version.

For I2C LED application snippet:

     Copy the content of the i2c_led.7z source to .../apps/snip/i2c_led


For BCM943362WCD4:

     Copy the content of the BCM943362WCD4.7z source to .../platforms/BCM943362WCD4


For BCM943341WCD1:

     Copy the content of the BCM943341WCD1.7z source to .../platforms/BCM943341WCD1


3. To build, download and run the application below

For STM32F4xx MCU BCM943341WCD1:

     snip.i2c_led-BCM943341WCD1-debug download run


For STM32F2xx MCU BCM943362WCD4:

     snip.i2c_led-BCM943362WCD4-debug download run



This is the modified STM32F4xx MCU BCM943341WCD1 WICED evaluation board:


NOTE: There are no hardware nor platform file changes needed on the BCM943341WCD1 evaluation because the already defined I2C lines ,with pull-up resistors, are used.


This is the modified STM32F2xx MCU BCM943362WCD4 Wiced evaluation board:


NOTE: On BCM943362WCD4 evaluation board, SDA and SCL signals needs 4.7K pull up resistors.

This application snippet demonstrates the e-mail capability based on the state changes on the selected input.


The selected input could be discrete or analog input. Input could be the current temperature, security device going off, PIR detector, reed switch output, etc. For this example discrete input is used and the input is toggled by the push button switch (SW1) on the evaluation board.


To setup the application, please download the attached push2email snipped application and copy it to the WICED -SDK. For example the .../apps/snip directory of the WICED SDK.


Using .../apps/snip/push2email/wifi_config_dct.h, update the wi-fi configuration for WICED target platform board to connect to your network.

     Change the CLIENT_AP_SSID with your access point SSID.

     Change the CLIENT_AP_PASSPHRASE with your access point's security code.


You should change the "" email address with your own email address, in the push2email.c file. This should first be changed after #define RECIPIENT (line 48) and then again in the section to setup email account (line 168).


Build the push2email application and download it to your target

     snip.push2email-<YourPlatform> download run


For BCM943362WCD4 WICED evaluation board make target would be as following:

     snip.push2email-BCM943362WCD4 download run


When the push2email application runs on the target, the initial state of the LED1, based on the state of the SW1 switch, is sent as an email to the recipient. The following would be received by the email recipient: "WICED device is up initial LED state is ON."


As the SW1 switch is pressed to toggle the LED1 state, the state changes of the LED1 are sent to email recipient.


With new smtp signin security added by the mail service providers, embedded devices sign-in is prevented. The email address is created for demo purposes and the sign-in is set to access for less secure apps. Similar sign-in setup may require to send mail using your own smtp server. To receive email no such setup is required but Wiced device generated emails may end up in spam folder.

Filter Blog

By date:
By tag: