-
Notifications
You must be signed in to change notification settings - Fork 23
/
busdevice.h
47 lines (31 loc) · 1.69 KB
/
busdevice.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//HW interface to phyiscal bus device
#ifndef SM_BUSDEVICE
#define SM_BUSDEVICE
#include "simplemotion.h"
#include "simplemotion_private.h"
typedef smint16 smbusdevicehandle;
#define SM_BAUDRATE 460800
//ie "COM1" "VSD2USB"
//return 0-1 if fails, otherwise handle number
smbusdevicehandle smBDOpen( const char *devicename );
smbusdevicehandle smBDOpenWithCallbacks(const char *devicename, BusdeviceOpen busOpenCallback, BusdeviceClose busCloseCallback, BusdeviceReadBuffer busReadCallback, BusdeviceWriteBuffer busWriteCallback , BusdeviceMiscOperation busMiscOperationCallback);
//return true if ok
smbool smBDClose( const smbusdevicehandle handle );
//write one byte to trasmit buffer. send data with smBDTransmit()
//returns smtrue on success. smfalse could mean buffer full error if forgot to call smBDTransmit
smbool smBDWrite( const smbusdevicehandle handle , const smuint8 byte );
//write transmit buffer to physical device
//returns true on success
smbool smBDTransmit(const smbusdevicehandle handle);
//read one byte from bus. if byte not immediately available, block return up to SM_READ_TIMEOUT millisecs to wait data
//returns true if byte read sucessfully
smbool smBDRead( const smbusdevicehandle handle , smuint8 *byte );
//see info at definition of BusDeviceMiscOperationType
//returns true if sucessfully
smbool smBDMiscOperation( const smbusdevicehandle handle, BusDeviceMiscOperationType operation );
//BUS DEVICE INFO FETCH FUNCTIONS:
// Return number of bus devices found. details of each device may be consequently fetched by smBDGetBusDeviceDetails()
smint smBDGetNumberOfDetectedBuses();
//return smtrue if success
smbool smBDGetBusDeviceDetails( smint index, SM_BUS_DEVICE_INFO *info );
#endif