0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

OpenHarmony:全流程講解如何編寫RTC平臺(tái)驅(qū)動(dòng)以及應(yīng)用程序

福州市凌睿智捷電子有限公司 ? 2023-09-19 10:14 ? 次閱讀

1、程序介紹

本程序是基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)編寫的平臺(tái)驅(qū)動(dòng)案例:RTC

2、基礎(chǔ)知識(shí)

2.1、RTC簡介

RTC(real-time clock)為操作系統(tǒng)中的實(shí)時(shí)時(shí)鐘設(shè)備,為操作系統(tǒng)提供精準(zhǔn)的實(shí)時(shí)時(shí)間和定時(shí)報(bào)警功能。當(dāng)設(shè)備下電后,通過外置電池供電,RTC繼續(xù)記錄操作系統(tǒng)時(shí)間;設(shè)備上電后,RTC提供實(shí)時(shí)時(shí)鐘給操作系統(tǒng),確保斷電后系統(tǒng)時(shí)間的連續(xù)性。

2.2、RTC驅(qū)動(dòng)開發(fā)

在HDF框架中,RTC的接口適配模式采用獨(dú)立服務(wù)模式,在這種模式下,每一個(gè)設(shè)備對象會(huì)獨(dú)立發(fā)布一個(gè)設(shè)備服務(wù)來處理外部訪問,設(shè)備管理器收到API的訪問請求之后,通過提取該請求的參數(shù),達(dá)到調(diào)用實(shí)際設(shè)備對象的相應(yīng)內(nèi)部方法的目的。獨(dú)立服務(wù)模式可以直接借助HDFDeviceManager的服務(wù)管理能力,但需要為每個(gè)設(shè)備單獨(dú)配置設(shè)備節(jié)點(diǎn),增加內(nèi)存占用。

獨(dú)立服務(wù)模式下,核心層不會(huì)統(tǒng)一發(fā)布一個(gè)服務(wù)供上層使用,因此這種模式下驅(qū)動(dòng)要為每個(gè)控制器發(fā)布一個(gè)服務(wù),具體表現(xiàn)為:

驅(qū)動(dòng)適配者需要實(shí)現(xiàn)HdfDriverEntry的Bind鉤子函數(shù)以綁定服務(wù)。

device_info.hcs文件中deviceNode的policy字段為1或2,不能為0。

2.2.1、RTC驅(qū)動(dòng)開發(fā)接口

為了保證上層在調(diào)用RTC接口時(shí)能夠正確的操作硬件,核心層在//drivers/hdf_core/framework/support/platform/include/rtc/rtc_core.h中定義了以下鉤子函數(shù)。驅(qū)動(dòng)適配者需要在適配層實(shí)現(xiàn)這些函數(shù)的具體功能,并與這些鉤子函數(shù)掛接,從而完成接口層與核心層的交互。

RtcMethod定義:

struct RtcMethod { int32_t (*ReadTime)(struct RtcHost *host, struct RtcTime *time); int32_t (*WriteTime)(struct RtcHost *host, const struct RtcTime *time); int32_t (*ReadAlarm)(struct RtcHost *host, enum RtcAlarmIndex alarmIndex, struct RtcTime *time); int32_t (*WriteAlarm)(struct RtcHost *host, enum RtcAlarmIndex alarmIndex, const struct RtcTime *time); int32_t (*RegisterAlarmCallback)(struct RtcHost *host, enum RtcAlarmIndex alarmIndex, RtcAlarmCallback cb); int32_t (*AlarmInterruptEnable)(struct RtcHost *host, enum RtcAlarmIndex alarmIndex, uint8_t enable); int32_t (*GetFreq)(struct RtcHost *host, uint32_t *freq); int32_t (*SetFreq)(struct RtcHost *host, uint32_t freq); int32_t (*Reset)(struct RtcHost *host); int32_t (*ReadReg)(struct RtcHost *host, uint8_t usrDefIndex, uint8_t *value); int32_t (*WriteReg)(struct RtcHost *host, uint8_t usrDefIndex, uint8_t value);};

RtcMethod結(jié)構(gòu)體成員的鉤子函數(shù)功能說明:

42659030-5692-11ee-9788-92fbcf53809c.png

2.2.2、RTC驅(qū)動(dòng)開發(fā)步驟

RTC模塊適配HDF框架包含以下四個(gè)步驟:

實(shí)例化驅(qū)動(dòng)入口。

配置屬性文件。

實(shí)例化RTC控制器對象。

驅(qū)動(dòng)調(diào)試。

我們以//drivers/hdf_core/adapter/khdf/linux/platform/rtc/rtc_adapter.c為例(該rtc驅(qū)動(dòng)是建立于Linux rtc子系統(tǒng)基礎(chǔ)上創(chuàng)建)。

2.2.2.1、驅(qū)動(dòng)實(shí)例化驅(qū)動(dòng)入口

驅(qū)動(dòng)入口必須為HdfDriverEntry(在hdf_device_desc.h中定義)類型的全局變量,且moduleName要和device_info.hcs中保持一致。

HDF框架會(huì)將所有加載的驅(qū)動(dòng)的HdfDriverEntry對象首地址匯總,形成一個(gè)類似數(shù)組的段地址空間,方便上層調(diào)用。

一般在加載驅(qū)動(dòng)時(shí)HDF會(huì)先調(diào)用Bind函數(shù),再調(diào)用Init函數(shù)加載該驅(qū)動(dòng)。當(dāng)Init調(diào)用異常時(shí),HDF框架會(huì)調(diào)用Release釋放驅(qū)動(dòng)資源并退出。

rtc驅(qū)動(dòng)入口參考:

struct HdfDriverEntry g_rtcDriverEntry = { .moduleVersion = 1, .Bind = HiRtcBind, .Init = HiRtcInit, .Release = HiRtcRelease, .moduleName = "HDF_PLATFORM_RTC", //【必要且與HCS文件中里面的moduleName匹配】};/* 調(diào)用HDF_INIT將驅(qū)動(dòng)入口注冊到HDF框架中 */HDF_INIT(g_rtcDriverEntry);

2.2.2.2、配置屬性文件

deviceNode信息與驅(qū)動(dòng)入口注冊相關(guān),器件屬性值與核心層RTCCntlr成員的默認(rèn)值或限制范圍有密切關(guān)系。

本例只有一個(gè)RTC控制器,如有多個(gè)器件信息,則需要在device_info.hcs文件增加deviceNode信息。

本次案例以rk3568為案例(即文件//vendor/lockzhiner/rk3568/hdf_config/khdf/device_info/device_info.hcs),添加deviceNode描述,具體修改如下:

device_rtc :: device { device0 :: deviceNode { policy = 2; // 驅(qū)動(dòng)服務(wù)發(fā)布的策略,policy大于等于1(用戶態(tài)可見為2,僅內(nèi)核態(tài)可見為1) priority = 30; // 驅(qū)動(dòng)啟動(dòng)優(yōu)先級 permission = 0644; // 驅(qū)動(dòng)創(chuàng)建設(shè)備節(jié)點(diǎn)權(quán)限 moduleName = "HDF_PLATFORM_RTC"; // 驅(qū)動(dòng)名稱,該字段的值必須和驅(qū)動(dòng)入口結(jié)構(gòu)的moduleName值一致 serviceName = "HDF_PLATFORM_RTC"; // 驅(qū)動(dòng)對外發(fā)布服務(wù)的名稱,必須唯一 deviceMatchAttr = ""; // 驅(qū)動(dòng)私有數(shù)據(jù)匹配的關(guān)鍵字,必須和驅(qū)動(dòng)私有數(shù)據(jù)配置表中的match_attr值一致 }}

2.2.2.3、實(shí)例化RTC控制器對象

完成屬性文件配置之后,下一步就是以核心層RtcHost對象的初始化為核心,包括驅(qū)動(dòng)適配者自定義結(jié)構(gòu)體(傳遞參數(shù)和數(shù)據(jù)),實(shí)例化RtcHost成員RtcMethod(讓用戶可以通過接口來調(diào)用驅(qū)動(dòng)底層函數(shù)),實(shí)現(xiàn)HdfDriverEntry成員函數(shù)(Bind、Init、Release)。

RtcHost成員鉤子函數(shù)結(jié)構(gòu)體RtcMethod的實(shí)例化,其他成員在Init函數(shù)中初始化。

static int32_t HiRtcReadTime(struct RtcHost *host, struct RtcTime *hdfTime);static int32_t HiRtcWriteTime(struct RtcHost *host, const struct RtcTime *hdfTime);static int32_t HiReadAlarm(struct RtcHost *host, enum RtcAlarmIndex alarmIndex, struct RtcTime *hdfTime);static int32_t HiWriteAlarm(struct RtcHost *host, enum RtcAlarmIndex alarmIndex, const struct RtcTime *hdfTime);static int32_t HiAlarmInterruptEnable(struct RtcHost *host, enum RtcAlarmIndex alarmIndex, uint8_t enable);// 定義RtcMethod結(jié)構(gòu)體變量g_method,負(fù)責(zé)RTC相關(guān)接口static struct RtcMethod g_method = { .ReadTime = HiRtcReadTime, .WriteTime = HiRtcWriteTime, .ReadAlarm = HiReadAlarm, .WriteAlarm = HiWriteAlarm, .RegisterAlarmCallback = NULL, .AlarmInterruptEnable = HiAlarmInterruptEnable, .GetFreq = NULL, .SetFreq = NULL, .Reset = NULL, .ReadReg = NULL, .WriteReg = NULL,};

static int32_t HiRtcBind(struct HdfDeviceObject *device);static int32_t HiRtcInit(struct HdfDeviceObject *device);static void HiRtcRelease(struct HdfDeviceObject *device);struct HdfDriverEntry g_rtcDriverEntry = { .moduleVersion = 1, .Bind = HiRtcBind, .Init = HiRtcInit, .Release = HiRtcRelease, .moduleName = "HDF_PLATFORM_RTC", //【必要且與HCS文件中里面的moduleName匹配】};/* 調(diào)用HDF_INIT將驅(qū)動(dòng)入口注冊到HDF框架中 */HDF_INIT(g_rtcDriverEntry);

2.2.2.4、驅(qū)動(dòng)調(diào)試

建議先在Linux下修改確認(rèn),再移植到OpenHarmony。

2.3、RTC應(yīng)用開發(fā)

RTC主要用于提供實(shí)時(shí)時(shí)間和定時(shí)報(bào)警功能。

2.3.1、接口說明

RTC模塊提供的主要接口如表1所示,具體API詳見//drivers/hdf_core/framework/include/platform/rtc_if.h。

RTC驅(qū)動(dòng)API接口功能介紹如下所示:

4283f7d2-5692-11ee-9788-92fbcf53809c.png

(1)RtcOpen

RTC驅(qū)動(dòng)加載成功后,使用驅(qū)動(dòng)框架提供的查詢接口并調(diào)用RTC設(shè)備驅(qū)動(dòng)接口。

DevHandle RtcOpen(void);

RtcOpen參數(shù)定義如下:

42912740-5692-11ee-9788-92fbcf53809c.png

RtcOpen返回值定義如下:

42a0c22c-5692-11ee-9788-92fbcf53809c.png

假設(shè)系統(tǒng)中的RTC設(shè)備總線號(hào)為0,片選號(hào)為0,獲取該RTC設(shè)備句柄的示例如下:

DevHandle handle = NULL;

/* 獲取RTC句柄 */handle = RtcOpen();if (handle == NULL) { /* 錯(cuò)誤處理 */}

(2)RtcClose

銷毀RTC設(shè)備句柄,系統(tǒng)釋放對應(yīng)的資源。

void RtcClose(DevHandle handle);

RtcClose返回值定義如下:

42ac5baa-5692-11ee-9788-92fbcf53809c.png

(3)RtcReadTime

系統(tǒng)從RTC讀取時(shí)間信息,包括年、月、星期、日、時(shí)、分、秒、毫秒。

int32_t RtcReadTime(DevHandle handle, struct RtcTime *time);

RtcReadTime參數(shù)定義如下:

42bf4a3a-5692-11ee-9788-92fbcf53809c.png

RtcReadTime返回值定義如下:

42ce36a8-5692-11ee-9788-92fbcf53809c.png

(4)RtcWriteTime

設(shè)置RTC時(shí)間。

int32_t RtcWriteTime(DevHandle handle, struct RtcTime *time);

RtcWriteTime參數(shù)定義如下:

42dc54d6-5692-11ee-9788-92fbcf53809c.png

RtcWriteTime返回值定義如下:

42e90442-5692-11ee-9788-92fbcf53809c.png

(5)RtcReadAlarm

從rtc模塊中讀取定時(shí)報(bào)警時(shí)間。

int32_t RtcReadAlarm(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime *time);

RtcReadAlarm參數(shù)定義如下:

42f58230-5692-11ee-9788-92fbcf53809c.png

RtcReadAlarm返回值定義如下:

42fd31a6-5692-11ee-9788-92fbcf53809c.png

(6)RtcWriteAlarm

根據(jù)報(bào)警索引設(shè)置RTC報(bào)警時(shí)間。

int32_t RtcWriteAlarm(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct RtcTime \*time);

RtcWriteAlarm參數(shù)定義如下:

43116d92-5692-11ee-9788-92fbcf53809c.png

RtcWriteAlarm返回值定義如下:

431f7644-5692-11ee-9788-92fbcf53809c.png

(7)RtcRegisterAlarmCallback

系統(tǒng)啟動(dòng)后需要注冊RTC定時(shí)報(bào)警回調(diào)函數(shù),報(bào)警超時(shí)后觸發(fā)回調(diào)函數(shù)。

int32_t RtcRegisterAlarmCallback(DevHandle handle, enum RtcAlarmIndex alarmIndex, RtcAlarmCallback cb);

RtcRegisterAlarmCallback參數(shù)定義如下:

432f03de-5692-11ee-9788-92fbcf53809c.png

RtcRegisterAlarmCallback返回值定義如下:

433dcde2-5692-11ee-9788-92fbcf53809c.png

(8)RtcAlarmInterruptEnable

在啟動(dòng)報(bào)警操作前,需要先設(shè)置報(bào)警中斷使能,報(bào)警超時(shí)后會(huì)觸發(fā)告警回調(diào)函數(shù)。

int32_t RtcAlarmInterruptEnable(DevHandle handle, enum RtcAlarmIndex alarmIndex, uint8_t enable);

RtcAlarmInterruptEnable參數(shù)定義如下:

4352396c-5692-11ee-9788-92fbcf53809c.png

RtcAlarmInterruptEnable返回值定義如下:

43639072-5692-11ee-9788-92fbcf53809c.png

2.2.2、開發(fā)流程

使用rtc的一般流程如下圖所示:

4376abee-5692-11ee-9788-92fbcf53809c.png

3、程序解析

3.1、準(zhǔn)備工作

3.2、Linux內(nèi)核解析

3.2.1、創(chuàng)建Linux內(nèi)核Git

請參考《OpenHarmony如何為內(nèi)核打patch》(即Git倉庫的//docs/OpenHarmony如何為內(nèi)核打patch.docx)。

3.2.2、修改設(shè)備樹PWM7配置

修改//arch/arm64/boot/dts/rockchip/rk3568-lockzhiner-x0.dtsi(即該目錄是指已打Patch后的Linux內(nèi)核,不是OpenHarmony主目錄),具體如下所示:

&i2c5 {status = "okay";......
hym8563: hym8563@51 {compatible = "haoyu,hym8563";reg = <0x51>;pinctrl-names = "default";pinctrl-0 = <&rtc_int>;

interrupt-parent = <&gpio0>;interrupts = ;};}

設(shè)備樹中默認(rèn)是開啟rtc模塊的hym8563,讀者不用修改。

3.2.3、創(chuàng)建內(nèi)核patch

請參考《OpenHarmony如何為內(nèi)核打patch》(即Git倉庫的//docs/OpenHarmony如何為內(nèi)核打patch.docx)。

3.2.4、替換OpenHarmony的內(nèi)核patch

將制作出的kernel.patch替換到//kernel/linux/patches/linux-5.10/rk3568_patch/kernel.patch即可。

3.2.5、開啟內(nèi)核配置

修改///kernel/linux/config/linux-5.10/arch/arm64/configs/rk3568_standard_defconfig(即該目錄是指OpenHarmony主目錄),將CONFIG_DRIVERS_HDF_PLATFORM_RTC功能開啟,具體如下所示:

CONFIG_DRIVERS_HDF_PLATFORM_RTC=y

另外,Linux配置文件中需要定義rtc設(shè)備名稱定義,具體如下所示:

CONFIG_RTC_SYSTOHC_DEVICE="rtc0"

3.3、OpenHarmony配置樹配置

3.3.1、device_info.hcs

//vendor/lockzhiner/rk3568/hdf_config/khdf/device_info/device_info.hcs已定義好,具體如下:

device_rtc :: device { device0 :: deviceNode { policy = 2; priority = 30; permission = 0644; moduleName = "HDF_PLATFORM_RTC"; serviceName = "HDF_PLATFORM_RTC"; deviceMatchAttr = ""; }}

注意:

device0是rtc模塊,一般只需要1個(gè)rtc設(shè)備即可。

policy必須為2,表示對內(nèi)核態(tài)和用戶態(tài)提供服務(wù)。否則,應(yīng)用程序無法調(diào)用。

3.4、OpenHarmony RTC平臺(tái)驅(qū)動(dòng)

在//drivers/hdf_core/adapter/khdf/linux/platform/rtc/rtc_adapter.c已編寫對接Linux RTC驅(qū)動(dòng)的相關(guān)代碼,具體內(nèi)容如下:

static inline void HdfTimeToLinuxTime(const struct RtcTime *hdfTime, struct rtc_time *linuxTime){ linuxTime->tm_sec = hdfTime->second; linuxTime->tm_min = hdfTime->minute; linuxTime->tm_hour = hdfTime->hour; linuxTime->tm_mday = hdfTime->day; linuxTime->tm_mon = hdfTime->month - MONTH_DIFF; linuxTime->tm_year = hdfTime->year - YEAR_BASE; linuxTime->tm_wday = hdfTime->weekday; linuxTime->tm_yday = rtc_year_days(linuxTime->tm_mday, linuxTime->tm_mon, linuxTime->tm_year);}

static inline void LinuxTimeToHdfTime(struct RtcTime *hdfTime, const struct rtc_time *linuxTime){ hdfTime->second = linuxTime->tm_sec; hdfTime->minute = linuxTime->tm_min; hdfTime->hour = linuxTime->tm_hour; hdfTime->day = linuxTime->tm_mday; hdfTime->month = linuxTime->tm_mon + MONTH_DIFF; hdfTime->year = linuxTime->tm_year + YEAR_BASE; hdfTime->weekday = linuxTime->tm_wday;}

// 獲取Linux環(huán)境下的rtc設(shè)備接口static inline struct rtc_device *HdfGetRtcDevice(void){ // 獲取Linux環(huán)境下的rtc設(shè)備接口 struct rtc_device *dev = rtc_class_open(CONFIG_RTC_SYSTOHC_DEVICE); if (dev == NULL) { HDF_LOGE("%s: failed to get rtc device", __func__); } return dev;}

// 釋放Linux環(huán)境下的rtc設(shè)備接口static inline void HdfPutRtcDevice(struct rtc_device *dev){ rtc_class_close(dev);}

static int32_t HiRtcReadTime(struct RtcHost *host, struct RtcTime *hdfTime){ int32_t ret; struct rtc_time linuxTime = {0}; struct rtc_device *dev = HdfGetRtcDevice(); // 獲取Linux環(huán)境下的rtc設(shè)備接口

(void)host; if (dev == NULL) { return HDF_FAILURE; } ret = rtc_read_time(dev, &linuxTime); // 直接對Linux環(huán)境下的rtc設(shè)備接口進(jìn)行讀操作 if (ret < 0) { HDF_LOGE("%s: rtc_read_time error, ret is %d", __func__, ret); return ret; } HdfPutRtcDevice(dev); LinuxTimeToHdfTime(hdfTime, &linuxTime); return HDF_SUCCESS;}

該部分代碼不細(xì)述,感興趣的讀者可以去詳讀。

3.5、應(yīng)用程序

3.5.1、rtc_test.c

rtc相關(guān)頭文件如下所示:

#include "rtc_if.h" // rtc標(biāo)準(zhǔn)接口頭文件

主函數(shù)定義RTC接口調(diào)用,具體如下:

int main(int argc, char* argv[]){ int32_t ret = 0; DevHandle handle = NULL; struct RtcTime curTime; struct RtcTime alarmTime;

// 獲取RTC設(shè)備句柄 handle = RtcOpen(); if (handle == NULL) { PRINT_ERROR("RtcOpen failed\n"); return -1; }

// 讀取RTC實(shí)時(shí)時(shí)間 ret = RtcReadTime(handle, &curTime); if (ret != 0) { PRINT_ERROR("RtcReadTime failed and ret = %d\n", ret); goto out; } printf("RtcReadTime successful\n"); printf(" year = %d\n", curTime.year); printf(" month = %d\n", curTime.month); printf(" day = %d\n", curTime.day); printf(" hour = %d\n", curTime.hour); printf(" minute = %d\n", curTime.minute); printf(" second = %d\n", curTime.second); printf(" millisecond = %d\n", curTime.millisecond); // 設(shè)置RTC時(shí)間 curTime.year = 2023; curTime.month = 8; curTime.day = 28; curTime.hour = 17; curTime.minute = 45; curTime.second = 0; curTime.millisecond = 0; // 寫RTC時(shí)間信息 ret = RtcWriteTime(handle, &curTime); if (ret != 0) { PRINT_ERROR("RtcWriteTime failed and ret = %d\n", ret); goto out; } printf("RtcWriteTime successful\n"); printf(" year = %d\n", curTime.year); printf(" month = %d\n", curTime.month); printf(" day = %d\n", curTime.day); printf(" hour = %d\n", curTime.hour); printf(" minute = %d\n", curTime.minute); printf(" second = %d\n", curTime.second); printf(" millisecond = %d\n", curTime.millisecond);

// 該部分代碼,驅(qū)動(dòng)尚未完成#if 0 // 注冊報(bào)警A的定時(shí)回調(diào)函數(shù) ret = RtcRegisterAlarmCallback(handle, RTC_ALARM_INDEX_A, RtcAlarmCallback_DefaultFunc); if (ret != 0) { PRINT_ERROR("RtcRegisterAlarmCallback failed and ret = %d\n", ret); goto out; }

// 設(shè)置RTC報(bào)警時(shí)間 alarmTime.year = curTime.year; alarmTime.month = curTime.month; alarmTime.day = curTime.day; alarmTime.hour = curTime.hour; alarmTime.minute = curTime.minute; alarmTime.second = curTime.second + SLEEP_SEC; alarmTime.millisecond = curTime.millisecond; // 設(shè)置RTC_ALARM_INDEX_A索引定時(shí)器報(bào)警 ret = RtcWriteAlarm(handle, RTC_ALARM_INDEX_A, &alarmTime); if (ret != 0) { PRINT_ERROR("RtcWriteAlarm failed and ret = %d\n", ret); goto out; }

// 設(shè)置RTC報(bào)警中斷使能 ret = RtcAlarmInterruptEnable(handle, RTC_ALARM_INDEX_A, 1); if (ret != 0) { PRINT_ERROR("RtcAlarmInterruptEnable failed and ret = %d\n", ret); goto out; }

sleep(SLEEP_SEC + 5);#endif

out: RtcClose(handle); return ret;}

注意:由于目前rtc平臺(tái)驅(qū)動(dòng)沒有定義rtc定時(shí)器響應(yīng)函數(shù)接口,故rtc定時(shí)回調(diào)功能暫時(shí)關(guān)閉

3.5.2、BUILD.gn

編寫應(yīng)用程序的BUILD.gn,具體內(nèi)容如下:

import("http://build/ohos.gni")import("http://drivers/hdf_core/adapter/uhdf2/uhdf.gni")

print("samples: compile rk3568_rtc_test")ohos_executable("rk3568_rtc_test") { sources = [ "rtc_test.c" ] include_dirs = [ "$hdf_framework_path/include", "$hdf_framework_path/include/core", "$hdf_framework_path/include/osal", "$hdf_framework_path/include/platform", "$hdf_framework_path/include/utils", "$hdf_uhdf_path/osal/include", "$hdf_uhdf_path/ipc/include", "http://base/hiviewdfx/hilog/interfaces/native/kits/include", "http://third_party/bounds_checking_function/include", ]

deps = [ "$hdf_uhdf_path/platform:libhdf_platform", "$hdf_uhdf_path/utils:libhdf_utils", "http://base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", ]

cflags = [ "-Wall", "-Wextra", "-Werror", "-Wno-format", "-Wno-format-extra-args", ]

part_name = "product_rk3568" install_enable = true}

3.5.3、參與應(yīng)用程序編譯

編輯//vendor/lockzhiner/rk3568/samples/BUILD.gn,開啟編譯選項(xiàng)。具體如下:

"b09_platform_device_rtc/app:rk3568_rtc_test",

4、程序編譯

建議使用docker編譯方法,運(yùn)行如下:

hb set -root .hb set# 選擇lockzhiner下的rk3568編譯分支。hb build -f

5、運(yùn)行結(jié)果

運(yùn)行如下:

# rk3568_rtc_testRtcReadTime successful year = 2017 month = 8 day = 5 hour = 10 minute = 58 second = 9 millisecond = 0RtcWriteTime successful year = 2023 month = 8 day = 28 hour = 17 minute = 45 second = 0 millisecond = 0#

開發(fā)板重啟,可以發(fā)現(xiàn)系統(tǒng)相關(guān)時(shí)間已經(jīng)變更為我們案例中的配置。

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報(bào)投訴
  • 驅(qū)動(dòng)
    +關(guān)注

    關(guān)注

    12

    文章

    1813

    瀏覽量

    85051
  • RTC
    RTC
    +關(guān)注

    關(guān)注

    2

    文章

    519

    瀏覽量

    66129
  • OpenHarmony
    +關(guān)注

    關(guān)注

    25

    文章

    3611

    瀏覽量

    15965
收藏 人收藏

    評論

    相關(guān)推薦

    驅(qū)動(dòng)教程】iTOP-RK3568開發(fā)板進(jìn)行講解第十三期,主要講解輸入子系統(tǒng),共計(jì)24 講

    6.輸入子系統(tǒng)框架分析 7.輸入子系統(tǒng)關(guān)鍵數(shù)據(jù)結(jié)構(gòu)之間關(guān)系 8.認(rèn)識(shí)輸入子系統(tǒng)源碼以及裁剪 9.編寫一個(gè)最簡單的設(shè)備驅(qū)動(dòng)層代碼 10.通過最簡單設(shè)備驅(qū)動(dòng)代碼分析匹配規(guī)則和
    發(fā)表于 10-11 11:31

    基于ArkTS語言的OpenHarmony APP應(yīng)用開發(fā):HelloOpenharmony

    1、程序簡介該程序是基于OpenHarmony標(biāo)準(zhǔn)系統(tǒng)編寫的UI應(yīng)用類:HelloOpenHarmony。本案例是基于API9接口開發(fā)。本案
    的頭像 發(fā)表于 09-15 08:09 ?216次閱讀
    基于ArkTS語言的<b class='flag-5'>OpenHarmony</b> APP應(yīng)用開發(fā):Hello<b class='flag-5'>Openharmony</b>

    鴻蒙OpenHarmony【小型系統(tǒng) 編寫“Hello World”程序】 (基于Hi3516開發(fā)板)

    展示如何在單板上運(yùn)行第一個(gè)應(yīng)用程序,其中包括新建應(yīng)用程序、編譯、燒寫、運(yùn)行等步驟,最終輸出“Hello World!”。
    的頭像 發(fā)表于 05-10 16:26 ?623次閱讀
    鴻蒙<b class='flag-5'>OpenHarmony</b>【小型系統(tǒng) <b class='flag-5'>編寫</b>“Hello World”<b class='flag-5'>程序</b>】 (基于Hi3516開發(fā)板)

    鴻蒙OpenHarmony【標(biāo)準(zhǔn)系統(tǒng)編寫“Hello World”程序】 (基于RK3568開發(fā)板)

    編寫“Hello World”程序 下方將展示如何在單板上運(yùn)行第一個(gè)應(yīng)用程序,其中包括新建應(yīng)用程序、編譯、燒寫、運(yùn)行等步驟,最終輸出“Hello World!”。 前提條件 已參考[創(chuàng)
    的頭像 發(fā)表于 04-24 17:32 ?648次閱讀
    鴻蒙<b class='flag-5'>OpenHarmony</b>【標(biāo)準(zhǔn)系統(tǒng)<b class='flag-5'>編寫</b>“Hello World”<b class='flag-5'>程序</b>】 (基于RK3568開發(fā)板)

    鴻蒙OpenHarmony【小型系統(tǒng)編寫“Hello World”程序】 (基于Hi3516開發(fā)板)

    下方將展示如何在單板上運(yùn)行第一個(gè)應(yīng)用程序,其中包括新建應(yīng)用程序、編譯、燒寫、運(yùn)行等步驟,最終輸出“Hello World!”。
    的頭像 發(fā)表于 04-22 21:55 ?299次閱讀
    鴻蒙<b class='flag-5'>OpenHarmony</b>【小型系統(tǒng)<b class='flag-5'>編寫</b>“Hello World”<b class='flag-5'>程序</b>】 (基于Hi3516開發(fā)板)

    OpenHarmony內(nèi)核編程實(shí)戰(zhàn)

    編寫程序,讓開發(fā)板在串口調(diào)試工具中輸出”Hello,OpenHarmony“。▍操作在源碼的根目錄中有名為”applications“的文件,他存放著應(yīng)用程序樣例
    的頭像 發(fā)表于 03-27 08:31 ?633次閱讀
    <b class='flag-5'>OpenHarmony</b>內(nèi)核編程實(shí)戰(zhàn)

    怎么編寫Framebuffer驅(qū)動(dòng)程序

    Framebuffer 驅(qū)動(dòng)程序框架 分為上下兩層: fbmem.c:承上啟下 實(shí)現(xiàn)、注冊 file_operations 結(jié)構(gòu)體 把 APP 的調(diào)用向下轉(zhuǎn)發(fā)到具體的硬件驅(qū)動(dòng)程序
    的頭像 發(fā)表于 03-22 09:13 ?471次閱讀
    怎么<b class='flag-5'>編寫</b>Framebuffer<b class='flag-5'>驅(qū)動(dòng)程序</b>

    【從0開始創(chuàng)建AWTK應(yīng)用程序】編譯應(yīng)用到RTOS平臺(tái)

    AWStudio上編寫好AWTK應(yīng)用程序后,部署到RTOS平臺(tái)(如STM32)是很方便的,下面就以STM32F429型號(hào)為例子來介紹如何編譯AWTK應(yīng)用到RTOS
    的頭像 發(fā)表于 03-21 08:23 ?509次閱讀
    【從0開始創(chuàng)建AWTK<b class='flag-5'>應(yīng)用程序</b>】編譯應(yīng)用到RTOS<b class='flag-5'>平臺(tái)</b>

    RTC第二個(gè)功能和應(yīng)用程序

    一般RTC模塊設(shè)備管理時(shí)間日歷、計(jì)時(shí)器等。從年到二。一些愛普生RTC模塊可以通過使用來自32768 Hz的分割頻率來管理次第二功能。本文件描述了RTC模塊的三個(gè)具體的應(yīng)用程序。(表1)
    發(fā)表于 01-03 15:45 ?0次下載

    labview編寫程序的一般步驟

    。這包括確定需要控制或測量的設(shè)備、所需的輸入和輸出以及程序的功能和操作流程。 設(shè)計(jì)程序架構(gòu):根據(jù)程序需求,設(shè)計(jì)
    的頭像 發(fā)表于 12-29 10:06 ?1768次閱讀

    EDA流程的重要意義,以及國內(nèi)EDA流程進(jìn)展

    的方式。如果一款工具能夠覆蓋特定芯片在上述流程中的設(shè)計(jì)任務(wù),那么我們就將其稱之為流程EDA工具,或者是流程EDA
    的頭像 發(fā)表于 12-14 00:08 ?2139次閱讀

    linux驅(qū)動(dòng)程序的主要流程和功能

    介紹Linux驅(qū)動(dòng)程序的主要流程和功能。 一、驅(qū)動(dòng)程序的加載和初始化 Linux系統(tǒng)在啟動(dòng)過程中,會(huì)自動(dòng)加載已安裝的設(shè)備驅(qū)動(dòng)程序。加載驅(qū)動(dòng)程序
    的頭像 發(fā)表于 12-08 14:56 ?2063次閱讀

    開發(fā)java應(yīng)用程序的基本步驟是

    Java應(yīng)用程序。確定您希望應(yīng)用程序能夠執(zhí)行的任務(wù)和提供的功能。這將有助于指導(dǎo)您在開發(fā)過程中進(jìn)行決策并確定實(shí)現(xiàn)代碼的方式。 2.設(shè)計(jì)應(yīng)用程序:在開始編寫代碼之前,您應(yīng)該設(shè)計(jì)
    的頭像 發(fā)表于 11-28 16:52 ?1444次閱讀

    codeblocks怎么編寫程序

    Code::Blocks是一款免費(fèi)、開源的集成開發(fā)環(huán)境(IDE),它提供了一個(gè)方便的平臺(tái)編寫、調(diào)試和運(yùn)行C、C++以及其他編程語言的程序。在本篇文章中,我們將詳細(xì)討論如何使用Code
    的頭像 發(fā)表于 11-26 10:28 ?1273次閱讀

    如何把c語言源程序變成應(yīng)用程序

    將C語言源程序轉(zhuǎn)變?yōu)?b class='flag-5'>應(yīng)用程序可以分為以下幾個(gè)步驟:編寫源代碼、編譯、鏈接和運(yùn)行。在這篇文章中,我將詳細(xì)介紹這些步驟以及相關(guān)的工具和技術(shù)。 第一步是
    的頭像 發(fā)表于 11-26 09:04 ?3151次閱讀