aboutsummaryrefslogtreecommitdiff
path: root/busdevice.h
blob: 3cb4e24d7afa983501517bd26d06d6f696006481 (plain)
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

//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 );

//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 );


//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