| ISF 2.1 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

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