共1条
1/1 1 跳转至页
psos下驱动程序的开发(老站转)
target
工程师
来自:
发表总数:16
查看 短消息 电子邮件 引用 回复
--------------------------------------------------------------------------------
向pSOS+ I/O设备驱动表里加载驱动程序须编辑工作路径下的drv_conf.c这个文件.该文件包含一个SetUpDrivers ()函数的调用. SetUpDrivers ()函数的调用InstallDrivers()向I/O表里添加设备驱动程序.在SetUpDrivers ()函数里增加InstallDrivers()可以实现设备驱动程序的添加工作.函数原形如下所示:
SetUpDrivers: installs drivers in PsosIO table via a call to InstallDriver and then calls driver setup function if needed. NOTE: If the driver is to be part of the Network Interface then it should be placed in the SetUpNI function.
1.UCHAR *SetUpDrivers(UCHAR *FreeMemPtr)
INPUT: FreeMemPtr = A pointer to unused memory that can be used to allocate space for a driver.
NOTE: Be sure to advance FreeMemPtr if memory is allocates!
RETURNS: The new address of free memory after the drivers have allocated space.
NOTE: This function does many precompile checks so errors can be found during compile-time rather then at run- time.
2. InstallDriver( unsigned short major_number , /* device major number */
void (*dev_init)( ), /* device init procedure */
void (*dev_open)( ), /* device open procedure */
void (*dev_close)( ), /* device close procedure */
void (*dev_read)( ), /* device read procedure */
void (*dev_write)( ), /* device write procedure */
void (*dev_ioctl)( ), /* device control procedure */
unsigned long rsvd1, /* reserved it should be zero
unsigned short rsvd2,
unsigned short flags, /* flags =IO_AUTOINIT */
)
NOTE: If set to IO_AUTOINIT pSOS will automatically call the drivers initialization function. The SC_AUTOINIT #define which is set in sys_conf.h can be used to set this element.
InstallDriver() does not return a value. InstallDriver() assumes SC_DEVMAX is defined in sys_conf.h and is useful only before pSOS+ has been initialized.
If you are adding a driver that needs to be initialized before either pSOS+ is initialized or the driver's init function is called, then you can call a setup function (that you create) for the driver (for example, see the CnslSetup call for the serial device driver). If your initialization function needs to allocate memory, you may pass it the FreeMemPtr. The function should return a new FreeMemPtr which points to the end of the memory it has allocated.
/*
#if (defined(BSP_NEW_SERIAL) && !(BSP_NEW_SERIAL) && (BSP_SERIAL))
extern UCHAR *CnslSetup(UCHAR *FreeMem, ULONG defbaud, USHORT defcons);
#endif
*/
When adding code to install a new driver, it is a good idea to add precompile checks so errors can be found during compile-time rather then at run-time. Precompile checks are used, for example, in the code that installs the pSOSystem serial device driver below.
网络接口的增加与增加PSOS设备驱动程序基本相同.drv_conf.h包含SetUpNi( )函数的调用,该函数调用InstallNi( )在PNA+ 最初的接口表里加载每一个网络接口.函数原形如图所示:
UCHAR *SetUpNI(UCHAR *FreeMemPtr)
SetUpNI: Set up Network Interfaces for pNA+
INPUT: FreeMemPtr = A pointer to unused memory that can be used to allocate space for a driver. NOTE: Be sure to advance FreeMemPtr if memory is allocates!
RETURNS: The new address of free memory after the drivers have allocated space.
NOTES: This function does many precompile checks so errors can be found during compile-time rather then at run- time. Also, the Network Interface Table must be allocated before this function can be called. There cannot be more then NC_NNI entries in this table. NC_NNI is set in sys_conf.h. Before adding another interface, be sure to check sys_conf.h to see if NC_NNI is set to accommodate another one! See the pSOSystem Programmers Reference Manualfor more information. To add a Network driver to pSOSystem, call InstallNi(). This adds the Network Interface to the pNA+ Network Interface Table. */
InstallNi(
int (*entry)(), /* address of NI entry point */
int ipadd, /* IP address */
int mtu, /* maximum transmission length */
int hwalen, /* length of hardware address */
int flags, /* intErface flags */
int subnetaddr, /*subnet mask */
int dstipaddr /*destination ip address */
)
See pSOSystem Programmer`s Reference Manual, Configuration Tables Section, for more information about the Network Interface Table. InstallNi() does not return a value.
If you are adding a driver that needs to be initialized before either pSOS+ is initialized or the driver's init function is called, then you can call a setup function (that you create) for the driver (for example, see the CnslSetup call for the serial device driver). If your initialization function needs to allocate memory, you may pass it the FreeMemPtr. The function should return a new FreeMemPtr which points to the end of the memory it has allocated.
When adding code to install a new driver, it is a good idea to add precompile checks so errors can be found during compile-time rather then at run-time. Precompile checks are used, for example, in the code that installs the pSOSystem serial device driver below.
关键词: 驱动程序 开发 老站转 driver functi
共1条
1/1 1 跳转至页
回复
| 有奖活动 | |
|---|---|
| 2026年“我要开发板活动”第三季,开始了! | |
| 硬核工程师专属补给计划——填盲盒 | |
| “我踩过的那些坑”主题活动——第002期 | |
| 【EEPW电子工程师创研计划】技术变现通道已开启~ | |
| 发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
| 【EEPW在线】E起听工程师的声音! | |
| 高校联络员开始招募啦!有惊喜!! | |
| 【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
我要赚赏金打赏帖 |
|
|---|---|
| 以启明云端ESP32P4开发板实现TF卡读写功能被打赏¥28元 | |
| 【分享开发笔记,赚取电动螺丝刀】树莓派5串口UART0配置被打赏¥25元 | |
| 【STM32F103ZET6】17:分享在Rtos项目中断管理的使用经验被打赏¥23元 | |
| 【STM32F103ZET6】16:分享在中断中恢复串口任务,遇到的问题被打赏¥31元 | |
| 在FireBeetle2ESP32-C5上实现温度大气压检测及显示被打赏¥21元 | |
| 【分享开发笔记,赚取电动螺丝刀】SAME51双串口收发配置被打赏¥27元 | |
| Chaos-nano操作系统在手持式VOC检测设备上的应用被打赏¥37元 | |
| 【分享开发笔记,赚取电动螺丝刀】关于在导入第三方库lib时,wchart类型冲突的原因及解决方案被打赏¥30元 | |
| 在FireBeetle2ESP32-C5上实现温湿度检测和显示被打赏¥20元 | |
| 在FireBeetle2ESP32-C5上实现光照强度检测及显示被打赏¥21元 | |
我要赚赏金
