- How do utilize development board shields?
/* Project name:
* How do utilize development board shields?
* Copyright:
* (c) MIKROE, 2024.
* Description:
* - Example is meant for demonstrating Board Support Package
* functionality using mikroSDK 2.0.
* Library dependencies?
* - Make sure `Driver.GPIO.Out` and `Board` libraries are enabled
* NECTO's Library Manager to ensure a successful build.
* How to test this code example?
* - Make sure to create `LVGL Designer` type of a project within NECTO.
* - Navigate to NECTO's [Planet Debug](https://www.mikroe.com/planet-debug)
* feature, connect to one of the following
* [dev boards](https://github.com/MikroElektronika/mikrosdk_v2/tree/master/bsp/board/include/shields),
* flash the code, and freely test all the other preprocessor directives
* from `shield.h` header file.
*/
// ------------------------------------------------------------------ INCLUDES
/**
* Any initialization code needed for MCU to function properly.
* Do not remove this line or clock might not be set correctly.
*/
#ifdef PREINIT_SUPPORTED
#include "preinit.h"
#endif
#ifdef __GNUC__
#include "delays.h"
#endif
#include "display_lvgl.h"
#include "lv_port_indev.h"
#include "1ms_Timer.h"
#include "screens.h"
#include "board.h" // `board.h` has `shield.h` included
#include "drv_digital_out.h"
#include "delays.h"
// ----------------------------------------------------------------- USER CODE
void board_init()
{
lv_init();
lv_port_disp_init();
lv_port_indev_init();
// Configure 1ms interrupt.
timerInit();
}
void application_init()
{
//Initialize driver
board_init();
//Initialize all available screens
init_screens();
//Show main screen. If you want any other screen to show call its show function
show_main_screen();
// Initialize the LED pin as a digital output
digital_out_t led;
// Utilize preprocessor directive from `shield.h`
digital_out_init( &led, SHIELD_MIKROBUS_1_PWM );
// Turn the LED on
digital_out_high( &led );
Delay_ms(1000); // Wait for 1 second
// Turn the LED off
digital_out_low( &led );
Delay_ms(1000); // Wait for 1 second
}
int main(void)
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
//Call all initialization methods
application_init();
/////////////////////////////LVGL specific timing routine (DO NOT DELETE)/////////////////////////
while (1)
{
lv_task_handler();
Delay_ms(5);
}
/////////////////////////////////////////////////////////////////////////////////////////////////
}
static volatile uint32_t msCount = 0;
INTERRUPT_ROUTINE
{
msCount++;
if (5 == msCount) {
msCount = 0;
lv_tick_inc(5);
process_tp();
}
CLEAR_FLAG;
}