Kameleon STM32L4 library reference
Table of Contents
- kamami_l496_joy.h – Library for reading joystick switches with or without debouncing.
- kamami_l496_led.h – Library controls 8 LEDs available on Kameleon Board. You can turn on, turn off and toggle single LED or a group of LEDs.
- kamami_l496_led_rgb.h – Library controls RGB LED. Red, green and blue LEDs are controlled with PWM signal generated by 1st, 2nd and 3rd TIM4 channels.
- kamami_l496_pot.h – Library for reading potentiometer position. It uses 12-bit ADC.
- kamami_l496_temp.h – Library for reading temperature from STLM75M2F sensor using I2C.
- kamami_l496_mems.h – Library for reading data from LSM303C sensor using I2C.
- kamami_l496_temp.h – Library for VCOM USB communication.
- kamami_l496_qspi.h – Library for QSPI Winbond W25Q80DV Flash Memory.
- kamami_l496_7seg.h – Library for 4-digit 7-segment LED display.
- kamami_l496_motor.h – Motor controller library.
- kamami_l496_lcd.h – HD44780 LCD library.
- kamami_l496_audio.h – Library recording and playing audio data.
Joystick (kamami_l496_joy.h)
void joy_init(void)
uint16_t joy_update(void)
Return value:
Function returns joystick switches states as a combination of JOY_RIGHT, JOY_LEFT, JOY_DOWN, JOY_UP and JOY_OK constants.
uint16_t joy_get_state(void)
Return value:
Function returns joystick switches states as a combination of JOY_RIGHT, JOY_LEFT, JOY_DOWN, JOY_UP and JOY_OK constants.
uint16_t joy_get_raw_state(void)
Return value:
Function returns joystick switches states as a combination of JOY_RIGHT, JOY_LEFT, JOY_DOWN, JOY_UP and JOY_OK constants.
LEDs (kamami_l496_led.h)
void led_init(void)
void led_on(uint8_t led_num)
Parameters:
- led_num – Number of LED (0-7).
void led_off(uint8_t led_num)
Parameters:
- led_num – Number of LED (0-7).
void led_toggle(uint8_t led_num)
Parameters:
- led_num – Number of LED (0-7).
void led_set_mul(uint8_t led_msk)
Parameters:
- led_msk – Every bit controls single LED (0 – LED is off, 1 – LED is on).
void led_on_mul(uint8_t led_msk)
Parameters:
- led_msk – Mask determines which LEDs are turned on.
void led_off_mul(uint8_t led_msk)
Parameters:
- led_msk – Mask determines which LEDs are turned off.
void led_toggle_mul(uint8_t led_msk)
Parameters:
- led_msk – Mask determines which LEDs are toggled.
RGB LED (kamami_l496_led_rgb.h)
void led_rgb_init(void)
void led_rgb_set_intensity(uint8_t r_intensity, uint8_t g_intensity, uint8_t b_intensity)
Parameters:
- r_intensity – Red intensity (0-255).
- g_intensity – Green intensity (0-255).
- b_intensity – Blue intensity (0-255).
Potentiometer (kamami_l496_pot.h)
void pot_init(void)
uint16_t pot_read(void)
Return value:
12-bit unsigned value read from ADC.
STLM75M2F Temperature Sensor (kamami_l496_temp.h)
void temp_lm75_init(void)
int8_t temp_lm75_read(void)
Return value:
Temperature in Celsius degrees.
LSM303C 6DoF MEMS Sensor (accelerometer/magnetometer) (kamami_l496_mems.h)
uint8_t mems_init(uint8_t acc_datarate, uint8_t acc_fullscale)
Parameters:
- acc_datarate – Accelerometer data rate. Possible values are:
- MEMS_ACC_DATARATE_10HZ – 10Hz
- MEMS_ACC_DATARATE_50HZ – 50Hz
- MEMS_ACC_DATARATE_100HZ – 100Hz
- MEMS_ACC_DATARATE_200HZ – 200Hz
- MEMS_ACC_DATARATE_400HZ – 400Hz
- MEMS_ACC_DATARATE_800HZ – 800Hz
- acc_fullscale – Sets range of accelerometer measurement. Possible values are:
- MEMS_ACC_FULLSCALE_2G – -2G to 2G.
- MEMS_ACC_FULLSCALE_4G – -2G to 4G.
- MEMS_ACC_FULLSCALE_8G – -2G to 8G.
Return value:
Function returns 0 on success.
void mems_acc_read_xyz(struct mems_xyz_res* res)
Parameters:
- res – Pointer to mems_xyz_res struct.
int16_t mems_acc_read_x(void);
Return value:
Function returns acceleration value for X axis.
int16_t mems_acc_read_y(void);
Return value:
Function returns acceleration value for Y axis.
int16_t mems_acc_read_z(void);
Return value:
Function returns acceleration value for Z axis.
Virtual serial port (USB VCOM) (kamami_l496_temp.h)
void vcom_init(void)
void vcom_send(uint8_t* buf, uint32_t len)
Parameters:
- buf – Pointer to buffer with data to send.
- len – Number of bytes to send.
QSPI Flash Memory (kamami_l496_qspi.h)
void qspi_init(void)
void qspi_write(uint32_t address, uint8_t* buffer, uint32_t length)
Parameters:
- address – Address in QSPI Flash memory.
- buffer – Pointer to buffer with data to write.
- length – Number of bytes to write.
void qspi_read(uint32_t address, uint8_t* buffer, uint32_t length)
Parameters:
- address – Address in QSPI Flash memory.
- buffer – Pointer to buffer to write data read from QSPI Flash.
- length – Number of bytes to read.
void qspi_erase_sector(uint32_t address)
Parameters:
- address – Address in QSPI Flash memory.
void qspi_erase_chip(void)
4-digit 7-segment LED Display (kamami_l496_7seg.h)
void dis7seg_init (void)
uint8_t dis7seg_display(uint16_t value)
Parameters:
- value – Numerical value to display, value range is 0-9999.
Return value:
Returns 0 on success. If value is out of range then function returns 1.
uint8_t dis7seg_display_fixed_point(uint16_t value, uint8_t fraction_digits)
Parameters:
- value – Numerical value to display, value range is 0-9999.
- fraction_digits – Decimal dot position (0-3).
Return value:
Returns 0 on success. If value or fraction_digits is out of range then function returns 1.
Motor Controller (kamami_l496_motor.h)
void motor_init (void)
void motor_on(void)
void motor_off(void)
void motor_set_dir(uint8_t dir)
Parameters:
- dir – Motor direction, possible values: MOTOR_DIR_CLOCKWISE, MOTOR_DIR_COUNTERCLOCKWISE.
void motor_set_speed(uint8_t speed)
Parameters:
- speed – Motor speed, range 0-100.
2×16 LCD Display (HD44780 compatible) (kamami_l496_lcd.h)
void lcd_init(void)
void lcd_backlight_on (void)
void lcd_backlight_off (void)
void lcd_clear(void)
void lcd_display(char *data, uint8_t len, uint8_t row, uint8_t col)
Parameters:
- data – Pointer to buffer with data to display.
- len – Number of characters in buffer to display.
- row – Number of LCD row (1 or 2).
- data – Number of LCD column (1-16).
Microphone and Audio Amplifier (kamami_l496_audio.h)
void audio_init(void)
void audio_start_rec(uint8_t* buf, uint32_t len)
To handle buffer data you need to define functions:
1 2 |
void HAL_ADC_ConvHalfCpltCallback (ADC_HandleTypeDef* hadc) void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) |
Parameters:
- buf – Pointer to buffer for audio data.
- len – Buffer size.
void audio_stop_rec()
void audio_start_play(uint8_t* buf, uint32_t len)
To handle buffer data you need to define functions:
1 2 |
void HAL_DAC_ConvHalfCpltCallbackCh1 (DAC_HandleTypeDef* hdac) void HAL_DAC_ConvCpltCallbackCh1 (DAC_HandleTypeDef* hdac) |
Parameters:
- buf – Pointer to buffer with audio data.
- len – Buffer size.