format codes

This commit is contained in:
Meco Man 2022-01-09 07:19:55 -05:00
parent f21af8362b
commit b2b3fa6e27
17 changed files with 221 additions and 221 deletions

View File

@ -1,22 +1,22 @@
#include <stdio.h>
#include "app_phy.h"
#define PHY_BASE_ADDR 0x7
#define PHY_BASE_ADDR 0x7
#define PHY_REG_CONTROL 0x0
#define PHY_REG_STATUS 0x1
#define PHY_REG_ANE 0x6
#define PHY_REG_SPEC_STATUS 0x11
#define PHY_REG_EXTEND_STATUS 0x1B
#define PHY_REG_EXTEND_STATUS 0x1B
#define PHY_BIT_CONTROL_RESET 0x8000 /*!< Control reg : reset */
#define PHY_BIT_CONTROL_ANEN 0x1000 /*!< Control reg : auto-negotiation enable */
#define PHY_BIT_CONTROL_RSAN 0x0200 /*!< Control reg : auto-negotiation restart */
#define PHY_BIT_CONTROL_RESET 0x8000 /*!< Control reg : reset */
#define PHY_BIT_CONTROL_ANEN 0x1000 /*!< Control reg : auto-negotiation enable */
#define PHY_BIT_CONTROL_RSAN 0x0200 /*!< Control reg : auto-negotiation restart */
#define PHY_BIT_STATUS_ANC 0x0020 /*!< Status reg : auto-negotiation complete */
#define PHY_BIT_STATUS_LINK 0x0004 /*!< Status reg : link is up */
#define PHY_BIT_STATUS_ANC 0x0020 /*!< Status reg : auto-negotiation complete */
#define PHY_BIT_STATUS_LINK 0x0004 /*!< Status reg : link is up */
#define PHY_BIT_ANE_LPAN 0x0001 /*!< ANE reg : link partner can auto-neg */
#define PHY_BIT_ANE_LPAN 0x0001 /*!< ANE reg : link partner can auto-neg */
#define PHY_BIT_SPEED 0xC000 /*!< specific status reg : speed */
#define PHY_BIT_DUPLEX 0x2000 /*!< specific status reg : duplex */
@ -25,24 +25,24 @@
#define PHY_BIT_AUTO_MEDIA_REG_DISABLE 0x0200 /*!< extended status reg : auto media register select disable */
void phy_Reset() {
ETH_PhyWrite(PHY_BASE_ADDR, PHY_REG_CONTROL, PHY_BIT_CONTROL_RESET);
ETH_PhyWrite(PHY_BASE_ADDR, PHY_REG_CONTROL, PHY_BIT_CONTROL_RESET);
while (1) {
uint32_t ret = ETH_PhyRead(PHY_BASE_ADDR, PHY_REG_CONTROL);
if ((ret & PHY_BIT_CONTROL_RESET) == 0) {
break;
}
}
while (1) {
uint32_t ret = ETH_PhyRead(PHY_BASE_ADDR, PHY_REG_CONTROL);
if ((ret & PHY_BIT_CONTROL_RESET) == 0) {
break;
}
}
}
void phy_AutoMediaSelect() {
uint32_t data;
uint32_t data;
// auto media and auto media register selection
data = ETH_PhyRead(PHY_BASE_ADDR, PHY_REG_EXTEND_STATUS);
data &= ~PHY_BIT_AUTO_MEDIA_DISABLE;
data &= ~PHY_BIT_AUTO_MEDIA_REG_DISABLE;
ETH_PhyWrite(PHY_BASE_ADDR, PHY_REG_EXTEND_STATUS, data);
// auto media and auto media register selection
data = ETH_PhyRead(PHY_BASE_ADDR, PHY_REG_EXTEND_STATUS);
data &= ~PHY_BIT_AUTO_MEDIA_DISABLE;
data &= ~PHY_BIT_AUTO_MEDIA_REG_DISABLE;
ETH_PhyWrite(PHY_BASE_ADDR, PHY_REG_EXTEND_STATUS, data);
}
void phy_AutoNeg()
@ -65,61 +65,61 @@ void phy_AutoNeg()
}
BOOL phy_IsLink() {
uint32_t ret = ETH_PhyRead(PHY_BASE_ADDR, PHY_REG_STATUS);
return (ret & PHY_BIT_STATUS_LINK) ? TRUE : FALSE;
uint32_t ret = ETH_PhyRead(PHY_BASE_ADDR, PHY_REG_STATUS);
return (ret & PHY_BIT_STATUS_LINK) ? TRUE : FALSE;
}
BOOL phy_PartnerCanAutoNeg() {
uint32_t ret = ETH_PhyRead(PHY_BASE_ADDR, PHY_REG_ANE);
return (ret & PHY_BIT_ANE_LPAN) ? TRUE : FALSE;
uint32_t ret = ETH_PhyRead(PHY_BASE_ADDR, PHY_REG_ANE);
return (ret & PHY_BIT_ANE_LPAN) ? TRUE : FALSE;
}
uint32_t phy_GetSpeed() {
uint32_t ret = ETH_PhyRead(PHY_BASE_ADDR, PHY_REG_SPEC_STATUS);
return ((ret & PHY_BIT_SPEED) >> 14);
uint32_t ret = ETH_PhyRead(PHY_BASE_ADDR, PHY_REG_SPEC_STATUS);
return ((ret & PHY_BIT_SPEED) >> 14);
}
uint32_t phy_GetDuplex() {
uint32_t ret = ETH_PhyRead(PHY_BASE_ADDR, PHY_REG_SPEC_STATUS);
return ((ret & PHY_BIT_DUPLEX) >> 13);
uint32_t ret = ETH_PhyRead(PHY_BASE_ADDR, PHY_REG_SPEC_STATUS);
return ((ret & PHY_BIT_DUPLEX) >> 13);
}
BOOL phy_Init() {
phy_AutoMediaSelect();
phy_AutoNeg();
phy_AutoMediaSelect();
phy_AutoNeg();
if (!phy_PartnerCanAutoNeg()) {
printf("Warning:: PHY's partner can't do auto-negotiation\n");
}
if (!phy_PartnerCanAutoNeg()) {
printf("Warning:: PHY's partner can't do auto-negotiation\n");
}
if (!phy_IsLink()) {
printf("link is down\n");
return FALSE;
}
if (!phy_IsLink()) {
printf("link is down\n");
return FALSE;
}
{
uint32_t speed = phy_GetSpeed();
if (speed == PHY_SPEED_10) {
speed = 10;
} else if (speed == PHY_SPEED_100) {
speed = 100;
} else if (speed == PHY_SPEED_1000) {
speed = 1000;
}
{
uint32_t speed = phy_GetSpeed();
if (speed == PHY_SPEED_10) {
speed = 10;
} else if (speed == PHY_SPEED_100) {
speed = 100;
} else if (speed == PHY_SPEED_1000) {
speed = 1000;
}
printf("PHY runs in %dM speed %s duplex\n",
speed, (phy_GetDuplex() == PHY_DUPLEX_HALF) ? "half" : "full");
}
printf("PHY runs in %dM speed %s duplex\n",
speed, (phy_GetDuplex() == PHY_DUPLEX_HALF) ? "half" : "full");
}
// After auto-negcioation, Mawell PHY need some
// time to initial itself.
// So we have to delay some time since different
// connection way, such as direct wire, hub, switch.
// If not to delay, the first several sent frame
// may be lost.
// Please according to actual environment to tune
// this delay.
udelay(200000);
// After auto-negcioation, Mawell PHY need some
// time to initial itself.
// So we have to delay some time since different
// connection way, such as direct wire, hub, switch.
// If not to delay, the first several sent frame
// may be lost.
// Please according to actual environment to tune
// this delay.
udelay(200000);
return TRUE;
return TRUE;
}

View File

@ -7,13 +7,13 @@
#include "cmem7_includes.h"
#define PHY_SPEED_10 0x0 /*!< SPEED : 10M */
#define PHY_SPEED_100 0x1 /*!< SPEED : 100M */
#define PHY_SPEED_1000 0x2 /*!< SPEED : 1000M */
#define PHY_DUPLEX_HALF 0x0 /*!< DUPLEX : half */
#define PHY_DUPLEX_FULL 0x1 /*!< DUPLEX : full */
#define PHY_SPEED_10 0x0 /*!< SPEED : 10M */
#define PHY_SPEED_100 0x1 /*!< SPEED : 100M */
#define PHY_SPEED_1000 0x2 /*!< SPEED : 1000M */
#define PHY_DUPLEX_HALF 0x0 /*!< DUPLEX : half */
#define PHY_DUPLEX_FULL 0x1 /*!< DUPLEX : full */
void phy_Reset(void);
void phy_AutoNeg(void);
BOOL phy_IsLink(void);
@ -26,7 +26,7 @@ BOOL phy_Init(void);
}
#endif
#endif
#endif

View File

@ -1,7 +1,7 @@
/*
* File : emac.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006-2014, RT-Thread Develop Team
* COPYRIGHT (C) 2006-2021, RT-Thread Develop Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@ -38,7 +38,7 @@ struct rt_cme_eth
struct eth_device parent;
/* interface address info. */
rt_uint8_t dev_addr[MAX_ADDR_LEN]; /* hw address */
rt_uint8_t dev_addr[MAX_ADDR_LEN]; /* hw address */
uint32_t ETH_Speed;
uint32_t ETH_Mode;
@ -95,8 +95,8 @@ uint32_t txTotalMemory = 0x2000;
BOOL isRxNoBuf = FALSE;
#define ETH_MAX_PACKET_SIZE 1520 /* ETH_HEADER + ETH_EXTRA + MAX_ETH_PAYLOAD + ETH_CRC */
#define ETH_RXBUFNB 4
#define ETH_TXBUFNB 2
#define ETH_RXBUFNB 4
#define ETH_TXBUFNB 2
struct eth_rx_buffer
{

View File

@ -32,23 +32,23 @@ static struct rt_serial_device serial2;
static rt_err_t CME_M7_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
{
struct CME_M7_uart* uart;
UART_InitTypeDef init;
UART_InitTypeDef init;
RT_ASSERT(serial != RT_NULL);
RT_ASSERT(cfg != RT_NULL);
uart = (struct CME_M7_uart *)serial->parent.user_data;
init.UART_BaudRate = cfg->baud_rate;
init.UART_StopBits = UART_StopBits_1;
init.UART_BaudRate = cfg->baud_rate;
init.UART_StopBits = UART_StopBits_1;
init.UART_Parity = UART_Parity_None;
init.UART_LoopBack = FALSE;
init.UART_RxEn = TRUE;
init.UART_CtsEn = FALSE;
init.UART_LoopBack = FALSE;
init.UART_RxEn = TRUE;
init.UART_CtsEn = FALSE;
UART_Init(uart->uart_device, &init);
uart->uart_device->RX_RESET = 1;
UART_Enable(uart->uart_device, TRUE);
UART_Enable(uart->uart_device, TRUE);
uart->uart_device->RX_RESET = 0;
return RT_EOK;
@ -67,24 +67,24 @@ static rt_err_t CME_M7_control(struct rt_serial_device *serial, int cmd, void *a
case RT_DEVICE_CTRL_CLR_INT:
/* disable rx irq */
NVIC_InitStructure.NVIC_IRQChannel = uart->irq;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = FALSE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = FALSE;
NVIC_Init(&NVIC_InitStructure);
UART_EnableInt(uart->uart_device, UART_Int_RxNotEmpty, FALSE);
UART_EnableInt(uart->uart_device, UART_Int_RxNotEmpty, FALSE);
break;
case RT_DEVICE_CTRL_SET_INT:
/* enable rx irq */
NVIC_InitStructure.NVIC_IRQChannel = uart->irq;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = TRUE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = TRUE;
NVIC_Init(&NVIC_InitStructure);
UART_ClearInt(uart->uart_device, UART_Int_RxNotEmpty);
UART_EnableInt(uart->uart_device, UART_Int_RxNotEmpty, TRUE);
UART_ClearInt(uart->uart_device, UART_Int_RxNotEmpty);
UART_EnableInt(uart->uart_device, UART_Int_RxNotEmpty, TRUE);
break;
}
@ -132,8 +132,8 @@ static const struct rt_uart_ops CME_M7_uart_ops =
int rt_hw_uart_init(void)
{
struct CME_M7_uart* uart;
struct rt_serial_device *serial;
struct CME_M7_uart* uart;
struct rt_serial_device *serial;
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
#ifdef RT_USING_UART0
@ -143,7 +143,7 @@ int rt_hw_uart_init(void)
serial->ops = &CME_M7_uart_ops;
serial->config = config;
/* register UART device */
/* register UART device */
rt_hw_serial_register(serial,
"uart0",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
@ -157,14 +157,14 @@ int rt_hw_uart_init(void)
serial->ops = &CME_M7_uart_ops;
serial->config = config;
/* register UART device */
/* register UART device */
rt_hw_serial_register(serial,
"uart2",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
uart);
#endif /* RT_USING_UART2 */
return RT_EOK;
return RT_EOK;
}
INIT_BOARD_EXPORT(rt_hw_uart_init);

View File

@ -65,7 +65,7 @@
#include <rtgui/widgets/box.h>
#include <rtgui/image.h>
#if defined(RTGUI_USING_DFS_FILERW)
#if defined(RTGUI_USING_DFS_FILERW)
#include <dfs_posix.h>
#define PATH_SEPARATOR '/'
#endif
@ -77,8 +77,8 @@ struct photo_event
{
struct rtgui_event_win win;
rt_uint32_t cmd;
rt_uint8_t* path;
rt_uint8_t* format;
rt_uint8_t* path;
rt_uint8_t* format;
};
/* Private defines -----------------------------------------------------------*/
@ -95,10 +95,10 @@ volatile rt_uint32_t rt_system_status = 0;
#if defined(RT_USING_RTGUI)
static rt_bool_t pic_view_event_handler(rtgui_object_t *object, rtgui_event_t *event)
{
rt_bool_t result;
rt_bool_t result;
rt_bool_t load = RT_FALSE;
result = rtgui_container_event_handler(object, event);
result = rtgui_container_event_handler(object, event);
switch(event->type)
{
@ -108,27 +108,27 @@ static rt_bool_t pic_view_event_handler(rtgui_object_t *object, rtgui_event_t *e
case RTGUI_EVENT_MOUSE_BUTTON:
{
struct rtgui_event_mouse *mouse = (struct rtgui_event_mouse *)event;
struct rtgui_event_mouse *mouse = (struct rtgui_event_mouse *)event;
if (mouse->button == RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP)
{
if (mouse->button == RTGUI_MOUSE_BUTTON_LEFT | RTGUI_MOUSE_BUTTON_UP)
{
rt_kprintf("APP: left click (%x)\n", mouse->button);
}
}
}
break;
}
if (load)
{
struct rtgui_dc* dc;
rtgui_rect_t rect;
{
struct rtgui_dc* dc;
rtgui_rect_t rect;
rtgui_image_t* image;
image = rtgui_image_create_from_file("jpg", "/test9.jpg", RT_FALSE);
// image = rtgui_image_create_from_file("bmp", "/test_565.bmp", RT_FALSE);
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(object));
if (dc == RT_NULL)
dc = rtgui_dc_begin_drawing(RTGUI_WIDGET(object));
if (dc == RT_NULL)
{
return result;
}
@ -138,9 +138,9 @@ static rt_bool_t pic_view_event_handler(rtgui_object_t *object, rtgui_event_t *e
rect.x1 +=10;
rect.y1 +=10;
if (image != RT_NULL)
if (image != RT_NULL)
{
rtgui_image_blit(image, dc, &rect);
rtgui_image_blit(image, dc, &rect);
rtgui_image_destroy(image);
}
else
@ -148,10 +148,10 @@ static rt_bool_t pic_view_event_handler(rtgui_object_t *object, rtgui_event_t *e
rt_kprintf("APP err: no image found!\n");
}
rtgui_dc_end_drawing(dc, RT_TRUE);
}
rtgui_dc_end_drawing(dc, RT_TRUE);
}
return result;
return result;
}
static void app_main(void *parameter)
@ -169,21 +169,21 @@ static void app_main(void *parameter)
lcd->control(lcd, RTGRAPHIC_CTRL_GET_INFO, (void *)&lcd_info);
rt_kprintf("LCD size: %dX%d\n", lcd_info.width, lcd_info.height);
/* create application */
struct rtgui_app *app;
app = rtgui_app_create("gui_app");
if (app == RT_NULL)
/* create application */
struct rtgui_app *app;
app = rtgui_app_create("gui_app");
if (app == RT_NULL)
{
rt_kprintf("Create application \"gui_app\" failed!\n");
return;
}
struct rtgui_rect rect1, rect2, rect3;
struct rtgui_rect rect1, rect2, rect3;
struct rtgui_win *win_info, *win_main, *win_hello;
struct rtgui_container *container;
struct rtgui_container *container;
struct rtgui_label* label;
rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect1);
rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect1);
rect2.x1 = rect1.x1;
rect2.y1 = 25;
rect2.x2 = rect1.x2;
@ -191,119 +191,119 @@ static void app_main(void *parameter)
rect1.y2 = 25;
/* create info window */
win_info = rtgui_win_create(RT_NULL, "info",
win_info = rtgui_win_create(RT_NULL, "info",
&rect1,
RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE);
if (win_info == RT_NULL)
{
if (win_info == RT_NULL)
{
rt_kprintf("Create window \"info\" failed!\n");
rtgui_app_destroy(app);
rtgui_app_destroy(app);
return;
}
}
/* create container in info window */
container = rtgui_container_create();
if (container == RT_NULL)
{
container = rtgui_container_create();
if (container == RT_NULL)
{
rt_kprintf("Create container failed!\n");
return;
}
rtgui_widget_set_rect(RTGUI_WIDGET(container), &rect1);
return;
}
rtgui_widget_set_rect(RTGUI_WIDGET(container), &rect1);
rtgui_container_add_child(RTGUI_CONTAINER(win_info), RTGUI_WIDGET(container));
/* create lable in info window */
label = rtgui_label_create("RT-Thread & RTGUI");
label = rtgui_label_create("RT-Thread & RTGUI");
if (label == RT_NULL)
{
rt_kprintf("Create lable failed!\n");
return;
}
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_LEFT;
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(label)) = red;
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_LEFT;
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(label)) = red;
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(label)) = white;
rect3.x1 = rect1.x1 + 5;
rect3.y1 = rect1.y1 + 5;
rect3.x2 = rect1.x2 - 5;
rect3.y2 = rect1.y2 - 5;
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect3);
rtgui_container_add_child(container, RTGUI_WIDGET(label));
rect3.x1 = rect1.x1 + 5;
rect3.y1 = rect1.y1 + 5;
rect3.x2 = rect1.x2 - 5;
rect3.y2 = rect1.y2 - 5;
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect3);
rtgui_container_add_child(container, RTGUI_WIDGET(label));
/* create main window */
win_main = rtgui_win_create(RT_NULL, "main",
win_main = rtgui_win_create(RT_NULL, "main",
&rect2,
RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE);
if (win_main == RT_NULL)
{
if (win_main == RT_NULL)
{
rt_kprintf("Create window \"main\" failed!\n");
rtgui_app_destroy(app);
rtgui_app_destroy(app);
return;
}
}
/* create container in main window */
container = rtgui_container_create();
if (container == RT_NULL)
{
container = rtgui_container_create();
if (container == RT_NULL)
{
rt_kprintf("Create container failed!\n");
return;
}
return;
}
rtgui_widget_set_rect(RTGUI_WIDGET(container), &rect2);
rtgui_widget_set_rect(RTGUI_WIDGET(container), &rect2);
rtgui_object_set_event_handler(RTGUI_OBJECT(container), pic_view_event_handler);
rtgui_container_add_child(RTGUI_CONTAINER(win_main), RTGUI_WIDGET(container));
/* create lable in main window */
label = rtgui_label_create("EFM32GG_DK3750 Kit");
label = rtgui_label_create("EFM32GG_DK3750 Kit");
if (label == RT_NULL)
{
rt_kprintf("Create lable failed!\n");
return;
}
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_LEFT;
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(label)) = white;
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_LEFT;
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(label)) = white;
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(label)) = blue;
rect3.x1 = rect2.x1 + 5;
rect3.y1 = rect2.y1 + 5;
rect3.x2 = rect2.x2 - 5;
rect3.y2 = rect2.y1 + 20;
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect3);
rtgui_container_add_child(container, RTGUI_WIDGET(label));
rect3.x1 = rect2.x1 + 5;
rect3.y1 = rect2.y1 + 5;
rect3.x2 = rect2.x2 - 5;
rect3.y2 = rect2.y1 + 20;
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect3);
rtgui_container_add_child(container, RTGUI_WIDGET(label));
/* create hello window */
rect3.x1 = 80;
rect3.y1 = 50;
rect3.x2 = 320 - 80;
rect3.y2 = 240 - 50;
win_hello = rtgui_win_create(RT_NULL, "hello",
rect3.x1 = 80;
rect3.y1 = 50;
rect3.x2 = 320 - 80;
rect3.y2 = 240 - 50;
win_hello = rtgui_win_create(RT_NULL, "hello",
&rect3,
RTGUI_WIN_STYLE_DEFAULT);
if (win_hello == RT_NULL)
{
if (win_hello == RT_NULL)
{
rt_kprintf("Create window \"hello\" failed!\n");
rtgui_app_destroy(app);
rtgui_app_destroy(app);
return;
}
}
/* create a box */
rtgui_box_t *box = rtgui_box_create(RTGUI_VERTICAL, RT_NULL);
if(box == RT_NULL)
if(box == RT_NULL)
{
rt_kprintf("Create box failed!\n");
return;
}
// rtgui_win_set_box(win_hello, box);
label = rtgui_label_create("šţÂŢ,íďĹÖ!");
if(label == RT_NULL)
label = rtgui_label_create("哈罗,盹胖!");
if(label == RT_NULL)
{
rt_kprintf("Create lable failed!\n");
return;
}
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(label)) = white;
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(label)) = white;
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(label)) = black;
RTGUI_WIDGET(label)->align = RTGUI_ALIGN_CENTER_HORIZONTAL | RTGUI_ALIGN_CENTER_VERTICAL;
rtgui_widget_set_miniwidth(RTGUI_WIDGET(label),130);
@ -322,18 +322,18 @@ static void app_main(void *parameter)
static rt_bool_t photo_view_event_handler(rtgui_object_t *object, rtgui_event_t *event)
{
rt_bool_t result = RT_FALSE;
rt_bool_t result = RT_FALSE;
struct photo_event *photo_event = (struct photo_event *)event;
result = rtgui_container_event_handler(object, event);
result = rtgui_container_event_handler(object, event);
rt_kprintf("container event %x\n", event->type);
struct rtgui_event_win* wevent = (struct rtgui_event_win*)event;
struct rtgui_event_win* wevent = (struct rtgui_event_win*)event;
rt_kprintf("wevent->wid %x\n", wevent->wid);
if ((event->type == RTGUI_EVENT_COMMAND) && \
(photo_event->cmd == APP_CMD_PHOTO_FRAME))
{
{
rtgui_rect_t rect;
rtgui_image_t* image;
struct rtgui_dc* dc;
@ -361,25 +361,25 @@ static rt_bool_t photo_view_event_handler(rtgui_object_t *object, rtgui_event_t
return RT_TRUE;
}
return result;
return result;
}
static rt_bool_t photo_lable_event_handler(rtgui_object_t *object, rtgui_event_t *event)
{
rt_bool_t result = RT_FALSE;
rt_bool_t result = RT_FALSE;
result = rtgui_label_event_handler(object, event);
result = rtgui_label_event_handler(object, event);
rt_kprintf("lable event %x\n", event->type);
if (event->type == RTGUI_EVENT_COMMAND)
{
{
struct photo_event *photo = (struct photo_event *)event;
rtgui_label_set_text((rtgui_label_t *)object, photo->path);
rt_kprintf("path %s\n", photo->path);
}
return result;
return result;
}
static void app_photo(void *parameter)
@ -399,64 +399,64 @@ static void app_photo(void *parameter)
lcd->control(lcd, RTGRAPHIC_CTRL_GET_INFO, (void *)&lcd_info);
rt_kprintf("LCD size: %dX%d\n", lcd_info.width, lcd_info.height);
/* create application */
struct rtgui_app *app;
app = rtgui_app_create("pho_app");
if (app == RT_NULL)
/* create application */
struct rtgui_app *app;
app = rtgui_app_create("pho_app");
if (app == RT_NULL)
{
rt_kprintf("Create application \"pho_app\" failed!\n");
return;
}
struct rtgui_rect rect1, rect2;
struct rtgui_rect rect1, rect2;
struct rtgui_win *window;
struct rtgui_container *container;
struct rtgui_container *container;
struct rtgui_label* label;
rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect1);
rtgui_graphic_driver_get_rect(rtgui_graphic_driver_get_default(), &rect1);
/* create window */
window = rtgui_win_create(RT_NULL, "photo",
window = rtgui_win_create(RT_NULL, "photo",
&rect1,
RTGUI_WIN_STYLE_NO_BORDER | RTGUI_WIN_STYLE_NO_TITLE);
if (window == RT_NULL)
{
if (window == RT_NULL)
{
rt_kprintf("Create window \"photo\" failed!\n");
rtgui_app_destroy(app);
rtgui_app_destroy(app);
return;
}
}
event->win.wid = window;
/* create container */
container = rtgui_container_create();
if (container == RT_NULL)
{
container = rtgui_container_create();
if (container == RT_NULL)
{
rt_kprintf("Create container failed!\n");
return;
}
rtgui_widget_set_rect(RTGUI_WIDGET(container), &rect1);
return;
}
rtgui_widget_set_rect(RTGUI_WIDGET(container), &rect1);
rtgui_object_set_event_handler(RTGUI_OBJECT(container), photo_view_event_handler);
rtgui_container_add_child(RTGUI_CONTAINER(window), RTGUI_WIDGET(container));
/* create lable in info window */
label = rtgui_label_create("Photo Frame Demo");
label = rtgui_label_create("Photo Frame Demo");
if (label == RT_NULL)
{
rt_kprintf("Create lable failed!\n");
return;
}
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_LEFT;
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(label)) = white;
RTGUI_WIDGET_TEXTALIGN(RTGUI_WIDGET(label)) = RTGUI_ALIGN_LEFT;
RTGUI_WIDGET_BACKGROUND(RTGUI_WIDGET(label)) = white;
RTGUI_WIDGET_FOREGROUND(RTGUI_WIDGET(label)) = blue;
rect2.x1 = rect1.x1;
rect2.y1 = rect1.y1;
rect2.x2 = rect1.x2;
rect2.y2 = 15;
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect2);
rtgui_widget_set_rect(RTGUI_WIDGET(label), &rect2);
rtgui_object_set_event_handler(RTGUI_OBJECT(label), photo_lable_event_handler);
rtgui_container_add_child(container, RTGUI_WIDGET(label));
rtgui_container_add_child(container, RTGUI_WIDGET(label));
rtgui_win_show(window, RT_FALSE);

View File

@ -39,4 +39,4 @@ int rt_hw_pin_init(void);
}
#endif
#endif /* __DRV_GPIO_H__ */
#endif /* __DRV_GPIO_H__ */

View File

@ -223,4 +223,4 @@ static int rt_hw_rtc_init(void)
return RT_EOK;
}
INIT_DEVICE_EXPORT(rt_hw_rtc_init);
#endif
#endif

View File

@ -34,7 +34,7 @@
#ifndef BSP_CLOCK_CFG_MAIN_OSC_POPULATED
#define BSP_CLOCK_CFG_MAIN_OSC_POPULATED (1)
#endif
#ifndef BSP_CLOCK_CFG_MAIN_OSC_CLOCK_SOURCE
#define BSP_CLOCK_CFG_MAIN_OSC_CLOCK_SOURCE (0)
#endif

View File

@ -18,4 +18,4 @@
[3] = BSP_PRV_IELS_ENUM(EVENT_SCI7_ERI), /* SCI7 ERI (Receive error) */
[4] = BSP_PRV_IELS_ENUM(EVENT_ICU_IRQ0), /* ICU IRQ0 (External pin interrupt 0) */
};
#endif
#endif

View File

@ -36,4 +36,4 @@
SCI7_ERI_IRQn = 3, /* SCI7 ERI (Receive error) */
ICU_IRQ0_IRQn = 4, /* ICU IRQ0 (External pin interrupt 0) */
} IRQn_Type;
#endif /* VECTOR_DATA_H */
#endif /* VECTOR_DATA_H */

View File

@ -14,7 +14,7 @@
#include <rtdevice.h>
#define LED3_PIN BSP_IO_PORT_01_PIN_06
#define USER_INPUT "P105"
#define USER_INPUT "P105"
void hal_entry(void)
{

View File

@ -15,4 +15,4 @@ extern int __bss_end;
void rt_hw_board_init();
#endif
#endif

View File

@ -344,4 +344,4 @@ static int rt_hw_zynqmp_eth_init(void)
return state;
}
INIT_DEVICE_EXPORT(rt_hw_zynqmp_eth_init);
INIT_DEVICE_EXPORT(rt_hw_zynqmp_eth_init);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@ -469,4 +469,4 @@ static int rh_hw_emmc_init(void)
return -RT_ERROR;
}
INIT_DEVICE_EXPORT(rh_hw_emmc_init);
#endif
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2020, RT-Thread Development Team
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@ -62,4 +62,4 @@ static int rt_hw_timer_init(void)
return RT_EOK;
}
INIT_BOARD_EXPORT(rt_hw_timer_init);
INIT_BOARD_EXPORT(rt_hw_timer_init);

View File

@ -45,4 +45,4 @@ extern "C" {
}
#endif
#endif
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2020, RT-Thread Development Team
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@ -315,4 +315,4 @@ int rt_hw_uart_init(void)
return RT_EOK;
}
INIT_BOARD_EXPORT(rt_hw_uart_init);
INIT_BOARD_EXPORT(rt_hw_uart_init);