| ISF 2.2 rev 5 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

isf_rli.c
Go to the documentation of this file.
1 /*
2 *
3 * Copyright (c) 2015, Freescale Semiconductor, Inc.
4 *
5 */
6 /*
7 * isf_rli.c
8 *
9 @file isf_rli.c
10 * @brief \b isf_rli.c defines the register level interfaces for the ISF. It establishes a designated communication
11 * channel to the device that enables seamless read/write operation on a register level.
12 */
13 #include "isf.h"
14 #include "isf_devmsg.h"
15 #include "isf_rli.h"
16 /***********************************************************************
17 *
18 * Function Name : isf_rli_init
19 * Description : This function initializes a rli channel.
20 * The Initialization creates the channel and initializes the data structures required to manage the channel.
21 * The channel is implicitly locked during the initialization.
22 *
23 ***************************************************************************/
24 RLI_CHANNEL_HANDLE* isf_rli_init(uint32 channelID)
25 {
26 // Allocate the memory for the descriptor
27 dm_ChannelDescriptor_t *pDescriptor = (dm_ChannelDescriptor_t *)OSA_MemAllocZero(sizeof(dm_ChannelDescriptor_t));
28 if(pDescriptor == NULL){
29 return NULL;
30 }
31 // Initialize the device channel and start the channel if its successful.
32 if(ISF_SUCCESS == dm_channel_init(channelID, pDescriptor)){
33 if(ISF_SUCCESS != dm_channel_start(pDescriptor)){
34 return NULL;
35 }
36 }else{
37 return NULL;
38 }
39 return (RLI_CHANNEL_HANDLE*)pDescriptor;
40 }
41 /***********************************************************************
42 *
43 * Function Name : isf_rli_open
44 * Description : This function creates a rli handle for a device at
45 * a specified channel address.
46 ***************************************************************************/
47 RLI_DEV_HANDLE* isf_rli_open(RLI_CHANNEL_HANDLE *pHdl, void *pSlaveInfo)
48 {
49 // Invalid Handle?
50 if(NULL == pHdl){
51 return NULL;
52 }
53 dm_DeviceDescriptor_t *pDescriptor = (dm_DeviceDescriptor_t *)OSA_MemAllocZero(sizeof(dm_DeviceDescriptor_t));
54 if(pDescriptor == NULL){
55 return NULL;
56 }
57 if(ISF_SUCCESS != dm_device_open(pHdl, pSlaveInfo, pDescriptor)){
58 return NULL;
59 }
60 return (RLI_DEV_HANDLE*)pDescriptor;
61 }
62 /***********************************************************************
63 *
64 * Function Name : isf_rli_write
65 * Description : This function writes data to the specified device.
66 *
67 ***************************************************************************/
68 isf_status_t isf_rli_write(RLI_DEV_HANDLE *pDevHdl, int32 startAddress, uint32 aNbyteWrite, uint8* apWriteBuffer )
69 {
70 // Invalid Handle?
71 if(NULL == pDevHdl){
72 return ISF_RLI_ERR_NULLPTR;
73 }
74 return dm_device_write(pDevHdl, startAddress, apWriteBuffer, aNbyteWrite, aNbyteWrite);
75
76 }
77 /***********************************************************************
78 *
79 * Function Name : isf_rli_read
80 * Description : This function reads from the device.Any data returned by the device is read
81 * and placed in the provided read buffer
82 ***************************************************************************/
83 isf_status_t isf_rli_read(RLI_DEV_HANDLE *pDevHdl, int32 startAddress, uint32 aNbyteRead, uint8* apReadBuffer)
84 {
85 // Invalid Handle?
86 if(NULL == pDevHdl){
87 return ISF_RLI_ERR_NULLPTR;
88 }
89 return dm_device_read(pDevHdl, startAddress, apReadBuffer, aNbyteRead, aNbyteRead);
90
91 }
92 /***********************************************************************
93 *
94 * Function Name : isf_rli_close
95 * Description : This function closes the device and releases the resource allocated during open.
96 ***************************************************************************/
97 isf_status_t isf_rli_close(RLI_DEV_HANDLE *pDevHdl)
98 {
99 if(NULL == pDevHdl){
100 return ISF_RLI_ERR_NULLPTR;
101 }
102 if(ISF_SUCCESS != dm_device_close(pDevHdl)){
103 return ISF_RLI_ERR_CLOSE;
104 }
105 OSA_MemFree(pDevHdl);
106 return ISF_SUCCESS;
107 }
108 /***********************************************************************
109 *
110 * Function Name : isf_rli_deint
111 * Description : This function de-initialize the channel and resources allocated during the initialization.
112 ***************************************************************************/
113 isf_status_t isf_rli_deint(RLI_CHANNEL_HANDLE *pHdl)
114 {
115 if(NULL == pHdl){
116 return ISF_RLI_ERR_NULLPTR;
117 }
118 OSA_MemFree(pHdl);
119 return ISF_SUCCESS;
120 }
121
dm_channel_start
isf_status_t dm_channel_start(dm_ChannelDescriptor_t *apChannelDescriptor)
This function starts a channel.
Definition: isf_device_messaging.c:137
isf_rli_deint
isf_status_t isf_rli_deint(RLI_CHANNEL_HANDLE *pHdl)
This function de-initialize the RLI channel.
Definition: isf_rli.c:113
uint8
unsigned char uint8
Definition: isf_types.h:76
RLI_CHANNEL_HANDLE
void RLI_CHANNEL_HANDLE
Definition: isf_rli.h:18
ISF_SUCCESS
Definition: isf.h:31
dm_device_open
isf_status_t dm_device_open(dm_ChannelDescriptor_t *apChannelDescriptor, void *apDevice, dm_DeviceDescriptor_t *apDeviceDescriptor)
This function creates a device handle for a device at a specified channel address.
Definition: isf_device_messaging.c:227
ISF_RLI_ERR_NULLPTR
Definition: isf_rli.h:37
isf_rli_open
RLI_DEV_HANDLE * isf_rli_open(RLI_CHANNEL_HANDLE *pHdl, void *pSlaveInfo)
This function creates a RLI connection handle at a specified device address.
Definition: isf_rli.c:47
isf_rli_init
RLI_CHANNEL_HANDLE * isf_rli_init(uint32 channelID)
This function initializes a register level interface.
Definition: isf_rli.c:24
dm_device_write
isf_status_t dm_device_write(dm_DeviceDescriptor_t *apDeviceDescriptor, int32 aOffset, uint8 *apWriteBuffer, uint32 aBuffsize, uint32 aNbyteWrite)
This function writes to a device.
Definition: isf_device_messaging.c:309
isf_rli_write
isf_status_t isf_rli_write(RLI_DEV_HANDLE *pDevHdl, int32 startAddress, uint32 aNbyteWrite, uint8 *apWriteBuffer)
This function writes to the device registers.
Definition: isf_rli.c:68
isf_rli_read
isf_status_t isf_rli_read(RLI_DEV_HANDLE *pDevHdl, int32 startAddress, uint32 aNbyteRead, uint8 *apReadBuffer)
This function reads from the device registers.
Definition: isf_rli.c:83
ISF_RLI_ERR_CLOSE
Definition: isf_rli.h:35
dm_channel_init
isf_status_t dm_channel_init(dm_ChannelId_t aChannelId, dm_ChannelDescriptor_t *apChannelDescriptor)
This function initializes a channel.
Definition: isf_device_messaging.c:48
dm_device_close
isf_status_t dm_device_close(dm_DeviceDescriptor_t *apDeviceDescriptor)
This function closes a device.
Definition: isf_device_messaging.c:252
isf_rli_close
isf_status_t isf_rli_close(RLI_DEV_HANDLE *pDevHdl)
This function closes the RLI connection.
Definition: isf_rli.c:97
isf.h
Main ISF header file. Contains code common to all ISF components.
int32
signed long int int32
Definition: isf_types.h:74
dm_device_read
isf_status_t dm_device_read(dm_DeviceDescriptor_t *apDeviceDescriptor, int32 aOffset, uint8 *apReadBuffer, uint32 aBuffsize, uint32 aNbyteRead)
This function reads from a device.
Definition: isf_device_messaging.c:271
isf_status_t
int32 isf_status_t
ISF return status type.
Definition: isf.h:76
isf_rli.h
RLI_DEV_HANDLE
void RLI_DEV_HANDLE
Definition: isf_rli.h:19
uint32
unsigned long int uint32
Definition: isf_types.h:78
dm_DeviceDescriptor_struct
This structure defines a handle for the device.
Definition: isf_devmsg.h:61
isf_devmsg.h
isf_devmsg.h defines the API definitions and types for the Intelligent Sensing (ISF) Device Messaging...
dm_ChannelDescriptor_struct
This structure is a declaration of a channel descriptor type.
Definition: isf_devmsg.h:50
- © Freescale Semiconductor, Inc. 2016. All Rights Reserved.