在STM32f429发现

时间:2016-04-14 15:01:23

标签: lcd stm32f4discovery mbed

我是初学者,通常使用mbed OS和嵌入式编程,我想熟悉mbed OS和uvisor,我的目标是使用LCD屏幕打印或不打印安全盒中的秘密。 因此,当我使用mbed-library和uvisor禁用时,一切都运行良好。但是当我尝试启用uvisor库时,我的程序停止工作。我尝试使用mbed OS + uvisor实现一个简单的例子,它运行良好。我希望你能帮助我,提前谢谢你。

这是我的代码: main.cpp中:

#include "mbed-drivers/mbed.h"
#include "minar/minar.h"
#include "core-util/FunctionPointer.h"
#include "uvisor-lib/uvisor-lib.h"
#include "lcd.h"
#include "main.h"
#include "btn.h"


/* messages on LCD */
char uvisorhello[] = " *** uvisor-Hello ***";


using mbed::util::FunctionPointer0;

/* Create ACLs for main box. */
MAIN_ACL(g_main_acl);

/* Enable uVisor. */
UVISOR_SET_MODE_ACL(UVISOR_ENABLED, g_main_acl);

DigitalOut led(MAIN_LED);
DigitalOut red_led(RED_LED);


void toggle_led()
{
  led = !led;
}



void init_periph()
{

  /* Init LCD */
  init_LCD();

  /* Configure the pushbutton. */
  btn_init();
}


void main_prog()
{
  toggle_led();
}



void app_start(int, char**){

    init_periph();

    lcd_print(uvisorhello);

    minar::Scheduler::postCallback(toggle_led).period(minar::milliseconds(1500));

}

main.h:

void  lcd_print(char *str);
void lcd_clear();
void toggle_led();

#define LED_ON  true
#define LED_OFF false

#define MAIN_LED LED1
#define RED_LED LED2

#define MAIN_BTN USER_BUTTON
#define MAIN_BTN_PD PullDown



#define MAIN_ACL(acl_list_name)                           \
    static const UvisorBoxAclItem acl_list_name[] = {     \
        {TIM2,   sizeof(*TIM2),   UVISOR_TACLDEF_PERIPH}, \
        {TIM5,   sizeof(*TIM5),   UVISOR_TACLDEF_PERIPH}, \
        {GPIOA,  sizeof(*GPIOA),  UVISOR_TACLDEF_PERIPH}, \
        {GPIOG,  sizeof(*GPIOG),  UVISOR_TACLDEF_PERIPH}, \
        {GPIOC, sizeof(*GPIOC), UVISOR_TACLDEF_PERIPH}, \
        {GPIOD, sizeof(*GPIOD), UVISOR_TACLDEF_PERIPH}, \
        {GPIOF, sizeof(*GPIOF), UVISOR_TACLDEF_PERIPH}, \
        {SPI5, sizeof(*SPI5), UVISOR_TACLDEF_PERIPH}, \
        /* FIXME: Secure RCC/EXTI/SYSCFG/FLASH */         \
        {RCC,    sizeof(*RCC),    UVISOR_TACLDEF_PERIPH}, \
        {EXTI,   sizeof(*EXTI),   UVISOR_TACLDEF_PERIPH}, \
        {SYSCFG, sizeof(*SYSCFG), UVISOR_TACLDEF_PERIPH}, \
        {FLASH,  sizeof(*FLASH),  UVISOR_TACLDEF_PERIPH}, \
        {PWR,    sizeof(*PWR),    UVISOR_TACLDEF_PERIPH}, \
        {(void *) 0x42470000, 0x1000, UVISOR_TACLDEF_PERIPH}, \
    }

lcd.cpp:

  #include "lcd.h"




/* Font size structure */
TM_FONT_SIZE_t FontSize;


void init_LCD()
{

  /* Init LCD */
  TM_LCD_Init();

  /* Fill LCD with color */
  //TM_LCD_Fill(0x4321);


}

void lcd_print(char *str)
{
  /* Verify if the bottom of the screen is reached*/
  if(TM_LCD_GetCurrentY()>TM_LCD_GetHeight())  lcd_clear();
  /* Put string to LCD */
  TM_LCD_Puts(str);
}

void lcd_clear()
{
  TM_LCD_SetXY(0,0);
  TM_LCD_Fill(0xFFFF);
}

lcd.h用于

#include "lib/stm32fxxx_hal.h"
#include "lib/tm_stm32_disco.h"
#include "lib/tm_stm32_delay.h"
#include "lib/tm_stm32_lcd.h"
#include "main.h"


void init_LCD();
void lcd_print(char *str);
void lcd_clear();

0 个答案:

没有答案