Răsfoiți Sursa

[DeviceDrivers] change RT_DEVICE_CTRL_RTC_* to rtc.h

BernardXiong 3 ani în urmă
părinte
comite
fc1faa123d

+ 4 - 0
components/drivers/Kconfig

@@ -318,6 +318,10 @@ config RT_USING_TOUCH
     bool "Using Touch device drivers"
     default n
 
+config RT_USING_LCD
+    bool "Using LCD graphic drivers"
+    default n
+
 menuconfig RT_USING_HWCRYPTO
         bool "Using Hardware Crypto drivers"
         default n

+ 70 - 0
components/drivers/include/drivers/lcd.h

@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2006-2022, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2022-03-05     bernard      first version.
+ */
+
+#ifndef RT_LCD_H__
+#define RT_LCD_H__
+
+/* ioctls
+   0x46 is 'F'                                                          */
+
+#define FBIOGET_VSCREENINFO     0x4600
+#define FBIOPUT_VSCREENINFO     0x4601
+#define FBIOGET_FSCREENINFO     0x4602
+#define FBIOGETCMAP             0x4604
+#define FBIOPUTCMAP             0x4605
+#define FBIOPAN_DISPLAY         0x4606
+#define FBIO_CURSOR             0x4608
+/* #define FBIOGET_MONITORSPEC  0x460C */
+/* #define FBIOPUT_MONITORSPEC  0x460D */
+/* #define FBIOSWITCH_MONIBIT   0x460E */
+
+#define FBIOGET_CON2FBMAP       0x460F
+#define FBIOPUT_CON2FBMAP       0x4610
+#define FBIOBLANK               0x4611          /* arg: 0 or vesa level + 1 */
+#define FBIOGET_VBLANK          0x4612
+#define FBIO_ALLOC              0x4613
+#define FBIO_FREE               0x4614
+#define FBIOGET_GLYPH           0x4615
+#define FBIOGET_HWCINFO         0x4616
+#define FBIOPUT_MODEINFO        0x4617
+#define FBIOGET_DISPINFO        0x4618
+#define FBIO_WAITFORVSYNC       0x4620
+
+struct fb_bitfield
+{
+    uint32_t offset;        /* beginning of bitfield */
+    uint32_t length;        /* length of bitfield */
+    uint32_t msb_right;     /* != 0 : Most significant bit is */
+    /* right */
+};
+
+struct fb_var_screeninfo
+{
+    uint32_t xres;
+    uint32_t yres;
+
+    uint32_t bits_per_pixel;
+
+    struct fb_bitfield red;     /* bitfield in fb mem if true color, */
+    struct fb_bitfield green;   /* else only length is significant */
+    struct fb_bitfield blue;
+    struct fb_bitfield transp;  /* transparency         */
+};
+
+struct fb_fix_screeninfo
+{
+    char id[16];
+    unsigned long smem_start;
+    uint32_t smem_len;
+
+    uint32_t line_length;
+};
+
+#endif

+ 8 - 2
components/drivers/include/drivers/rtc.h

@@ -8,8 +8,14 @@
  * 2012-10-10     aozima       first version.
  */
 
-#ifndef __RTC_H__
-#define __RTC_H__
+#ifndef RTC_H__
+#define RTC_H__
+
+/* RTC device */
+#define RT_DEVICE_CTRL_RTC_GET_TIME     0x40            /**< get time */
+#define RT_DEVICE_CTRL_RTC_SET_TIME     0x41            /**< set time */
+#define RT_DEVICE_CTRL_RTC_GET_ALARM    0x42            /**< get alarm */
+#define RT_DEVICE_CTRL_RTC_SET_ALARM    0x43            /**< set alarm */
 
 rt_err_t set_date(rt_uint32_t year, rt_uint32_t month, rt_uint32_t day);
 rt_err_t set_time(rt_uint32_t hour, rt_uint32_t minute, rt_uint32_t second);

+ 4 - 0
components/drivers/include/rtdevice.h

@@ -143,6 +143,10 @@ extern "C" {
 #include "drivers/rt_inputcapture.h"
 #endif
 
+#ifdef RT_USING_LCD
+#include "drivers/lcd.h"
+#endif
+
 #ifdef __cplusplus
 }
 #endif

+ 4 - 3
components/drivers/rtc/rtc.c

@@ -11,12 +11,13 @@
  * 2018-02-16     armink       add auto sync time by NTP
  */
 
-#include <time.h>
-#include <string.h>
-#include <rtthread.h>
+#include <rtdevice.h>
 
 #ifdef RT_USING_RTC
 
+#include <time.h>
+#include <string.h>
+
 /* Using NTP auto sync RTC time */
 #ifdef RTC_SYNC_USING_NTP
 /* NTP first sync delay time for network connect, unit: second */

+ 1 - 1
components/libc/compilers/musl/time.c

@@ -7,7 +7,7 @@
  * Date           Author       Notes
  */
 #include <sys/time.h>
-#include <rtthread.h>
+#include <rtdevice.h>
 
 #ifdef RT_USING_DEVICE
 int gettimeofday(struct timeval *tp, void *ignore)

+ 1 - 1
components/libc/time/clock_time.c

@@ -9,7 +9,7 @@
  *                             which found by Rob <rdent@iinet.net.au>
  */
 
-#include <rtthread.h>
+#include <rtdevice.h>
 #include "clock_time.h"
 
 static struct timeval _timevalue;

+ 18 - 16
include/rtdef.h

@@ -1029,32 +1029,34 @@ enum rt_device_class_type
 
 /**
  * general device commands
+ * 0x01 - 0x1F general device control commands
+ * 0x20 - 0x3F udevice control commands
+ * 0x40 -      special device control commands
  */
 #define RT_DEVICE_CTRL_RESUME           0x01            /**< resume device */
 #define RT_DEVICE_CTRL_SUSPEND          0x02            /**< suspend device */
 #define RT_DEVICE_CTRL_CONFIG           0x03            /**< configure device */
 #define RT_DEVICE_CTRL_CLOSE            0x04            /**< close device */
 #define RT_DEVICE_CTRL_NOTIFY_SET       0x05            /**< set notify func */
-#define RT_DEVICE_CTRL_CONSOLE_OFLAG    0x06            /**< get console open flag */
-
-#define RT_DEVICE_CTRL_SET_INT          0x10            /**< set interrupt */
-#define RT_DEVICE_CTRL_CLR_INT          0x11            /**< clear interrupt */
-#define RT_DEVICE_CTRL_GET_INT          0x12            /**< get interrupt status */
+#define RT_DEVICE_CTRL_SET_INT          0x06            /**< set interrupt */
+#define RT_DEVICE_CTRL_CLR_INT          0x07            /**< clear interrupt */
+#define RT_DEVICE_CTRL_GET_INT          0x08            /**< get interrupt status */
+#define RT_DEVICE_CTRL_MASK             0x1f            /**< mask for contrl commands */
 
 /**
  * special device commands
  */
-#define RT_DEVICE_CTRL_CHAR_STREAM      0x10            /**< stream mode on char device */
-#define RT_DEVICE_CTRL_BLK_GETGEOME     0x10            /**< get geometry information   */
-#define RT_DEVICE_CTRL_BLK_SYNC         0x11            /**< flush data to block device */
-#define RT_DEVICE_CTRL_BLK_ERASE        0x12            /**< erase block on block device */
-#define RT_DEVICE_CTRL_BLK_AUTOREFRESH  0x13            /**< block device : enter/exit auto refresh mode */
-#define RT_DEVICE_CTRL_NETIF_GETMAC     0x10            /**< get mac address */
-#define RT_DEVICE_CTRL_MTD_FORMAT       0x10            /**< format a MTD device */
-#define RT_DEVICE_CTRL_RTC_GET_TIME     0x10            /**< get time */
-#define RT_DEVICE_CTRL_RTC_SET_TIME     0x11            /**< set time */
-#define RT_DEVICE_CTRL_RTC_GET_ALARM    0x12            /**< get alarm */
-#define RT_DEVICE_CTRL_RTC_SET_ALARM    0x13            /**< set alarm */
+/* console device */
+#define RT_DEVICE_CTRL_CONSOLE_OFLAG    0x40            /**< get console open flag */
+/* character device */
+#define RT_DEVICE_CTRL_CHAR_STREAM      0x40            /**< stream mode on char device */
+/* block device */
+#define RT_DEVICE_CTRL_BLK_GETGEOME     0x40            /**< get geometry information   */
+#define RT_DEVICE_CTRL_BLK_SYNC         0x41            /**< flush data to block device */
+#define RT_DEVICE_CTRL_BLK_ERASE        0x42            /**< erase block on block device */
+#define RT_DEVICE_CTRL_BLK_AUTOREFRESH  0x43            /**< block device : enter/exit auto refresh mode */
+/* net interface device*/
+#define RT_DEVICE_CTRL_NETIF_GETMAC     0x40            /**< get mac address */
 
 typedef struct rt_device *rt_device_t;