Skip to content

devcoons/stm32-drv-ldind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

LDIND DRIVER

Driver for LEDs control:

  • Turn ON a LED;
  • Turn OFF a LED;
  • Turn in ERROR condition a LED (100 ms period of blinking).

Supported Hardware

Functions Guide

  • ldind_init : LED initialization, if everything is ok the LED will blink once.
  • ldind_write : choose the LED status (ON, OFF or ERROR).

How to use

This driver requires a basic timer.

  • Include the header file drv_ldind.h.
  • In the .ioc file setup the LEDs GPIO port and a basic timer with a global interrupt (it works on 100 ms independently, no other parameters are required).
  • create the ldind_t instance:
    • gpio_port : LED GPIO port.
    • gpio_pin : LED GPIO pin.
    • mx_init : the .ioc autogenerated function where the GPIO is initialised.
    • active_high: the electrical characteristic of the LED (1 if it is activated high and 0 for the opposite).
    • htim: basic timer handler (ONLY for the LED that marks an ERROR condition).
    • clock_frequency_mhz: clock frequency used for the timer peripheral (ONLY for the LED that marks an ERROR condition).

Example

This example uses a STM32F429I board.

ldind_t ldind_red = {
		.gpio_port = GPIOG,
		.gpio_pin = GPIO_PIN_14,
		.mx_init = MX_GPIO_Init,
		.active_high = 1,
		.htim = &htim6,
		.clock_frequency_mhz = 16,

};

ldind_t ldind_green = {
		.gpio_port = GPIOG,
		.gpio_pin = GPIO_PIN_13,
		.mx_init = MX_GPIO_Init,
		.active_high = 1,
};

void test_drv_ldind(void)
{
	ldind_init(&ldind_red);
	ldind_init(&ldind_green);

	ldind_write(&ldind_red, C_ERROR);
	HAL_Delay(1000);
	ldind_write(&ldind_red, C_OFF);
	HAL_Delay(1000);
	ldind_write(&ldind_red, C_ERROR);
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages