共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 跳转至页
回复
我要赚赏金打赏帖 |
|
|---|---|
| 在K230DBOX上实现多时段语音提示功能被打赏¥14元 | |
| 使K230DBOX实现相机持续拍照功能被打赏¥12元 | |
| 基于K230DBOX的文本管理器设计被打赏¥14元 | |
| 基于K230DBOX的彩色画板功能实现被打赏¥15元 | |
| 在K230DBOX上实现音乐播放器功能被打赏¥15元 | |
| NXP MCU系列开发板MCULink固件升级方法【VSCode】被打赏¥28元 | |
| 三分钟快速搭建NXP MCU开发环境(VSCode)被打赏¥22元 | |
| 为遥控小车巧添功能被打赏¥26元 | |
| 【S32K3XX】FlexCAN 模块配置使用被打赏¥30元 | |
| 【S32K3XX】FlexCAN RAM 资源分配整理被打赏¥25元 | |
我要赚赏金
