Kameleon STM32L4 Project Templates, Library and Examples

Overview

Kameleon library is made for rapid microcontroller application development. The library archive includes code examples and project templates. You can create project with Kameleon library in two ways:
  • Create project with STM32CubeMX, then include HAL libraries and Kameleon library files (files are located in KAMeLeon-lib directory)
  • The easier way: use one of two project templates provided with the library: kameleon_template or kameleon_template_no_usb (without vCOM support)
To use library functions you need to include kamami_l496_xxx.h file in project main.c file and initialize it with xxx_init functions. You can find more details in Kameleon Library Reference.
DOWNLOAD LIBRARY
GO TO LIBRARY REFERENCE

INCLUDED EXAMPLES

  • LEDs + Joystick (kamami_l476_led)

    This example does not require any additional connections apart from those on board.

    At the beginning the program turns on all LEDs with led_on_mul function, then function HAL_Delay is called to wait 1 second, then led_off_mul turns off all LEDs. All these operations are executed in main.c. Code responsible for other program features is located in stm32l4xx_it.c file in function SysTick_Handler that handles SysTick timer interrupts, program displays "animations" depending on joystick position:

    • Left - LEDs 0 to 7 are turned on for 100ms each
    • Right - LEDs 7 to 0 are turned on for 100ms each
    • Down - LEDs 0 to 7 are turned off (while all other LEDs are on) for 100ms each
    • Up - LEDs 7 to 0 are turned off (while all other LEDs are on) for 100ms each
    • OK - all LEDs are on

  • RGB LED + Joystick (kamami_l476_led_rgb)

    This example does not require any additional connections apart from those on board.

    This example lets you control RGB LED color with joystick:

    • Left - increase red brightness
    • Right - increase blue brightness
    • Up - increase green brightness
    • Down - reset all colors to 0

    Code is located in SysTick interrupt handler function: SysTick_Handler in stm32l4xx_it.c file. Joystick switches states are checked every 50ms and depending on them variables storing red, green and blue brightnesses are updated, then function led_rgb_set_intensity sets LEDs brightnesses.

  • Potentiometer + 7-segment LED Display (kamami_l476_pot_7seg)

    This example does not require any additional connections apart from those on board.

    In this example potentiometer position is scaled to 0-1000 range and displayed on 7-segment LED display. Code is located in main.c file, in the main loop potentiometer position is read by pot_read, then it is scaled by multiplication by 1000 and division by 0xfff (greatest 12-bit value). Calculated value is displayed on 7-segment display with dis7seg_display function.

  • Temperature Sensor + 7-segment LED Display (kamami_l476_temp_7seg)

    This example does not require any additional connections apart from those on board. I2C ADDRESS jumper must be in 0x48 position.

    In this example temperature read from STLM75M2F sensor is displayed as integer value in Celsius degrees on 7-segment display. Code is located in main.c file, in the main loop temperature is read by temp_lm75_read function, the value is displayed on 7-segment LED display with dis7seg_display function.

  • Accelerometer + vCOM USB (kamami_l496_mems_vcom)

    This example requires connection to PC with USB cable and terminal program on PC (e.g. TeraTerm).

    In this example every second X, Y and Z acceleration values are sent by vCOM USB. Code is located in main.c file, in the main loop acceleration values are read by mems_acc_read_xyz function and converted to G units, then a string is formatted with sprintf function, next the string is sent by vcom_send function.

  • Motor + Joystick (kamami_l496_motor_control)

    This example requires DC motor connected to OUT1 and OUT2 connectors of MOTOR OUT terminal. Also an external power supply is required.

    In this example you can control motor speed with joystick. Code is located in main.c function, at the beginning motor controller gets enabled (motor_on) and motor direction is set (motor_set_dir). In the main loop joystick switches states are checked every 100ms, if joystick is in up or down position then varialble storing motor speed is updated and motor speed is set by motor_set_speed function.

  • Potentiometer + 2x16 LCD (kamami_l476_pot_lcd)

    This example requires 2x16 LCD display (HD44780 compatible) connected to Kameleon LCD connector.

    This example shows potentiometer position on LCD display. Code is located in main.c file, at the beginning program turns on LCD backlight, in the main loop potentiometer position is read by pot_read function, this value is converted to string with sprintf function, then display is cleared (lcd_clear) and message is displayed with lcd_display function.

  • QSPI Flash + Microphone + Audio Amplifier (kamami_l476_audio_rec)

    This example requires headphones connected to AUD-OUT or speaker connected to SPK-OUT.

    This example lets you record sound (put joystick in left position) and playback (put joystick in right position). RGB LED is set to red while recording and to green while playback. Code is located in main.c file. Audio recording and playback requires a buffer (data) and four functions for buffer handling:

    • void HAL_ADC_ConvHalfCpltCallback (ADC_HandleTypeDef* hadc) - called when half of buffer is reached while recording. First half of buffer is written to QSPI Flash, currently recorded data is stored in the second half of buffer
    • void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) - called when end of buffer is reached while recording. Second half of buffer is written to QSPI Flash, currently recorded data is stored in the first half of buffer
    • void HAL_DAC_ConvHalfCpltCallbackCh1 (DAC_HandleTypeDef* hdac) - called when half of buffer is reached while playback. Data is loaded from QSPI Flash to first half of buffer, data from second half of buffer is played
    • void HAL_DAC_ConvCpltCallbackCh1 (DAC_HandleTypeDef* hdac) - called when end of buffer is reached while playback. Data is loaded from QSPI Flash to second half of buffer, data from first half of buffer is played