diff options
author | Joe Zhao <ztuowen@gmail.com> | 2014-05-23 15:36:51 +0800 |
---|---|---|
committer | Joe Zhao <ztuowen@gmail.com> | 2014-05-23 15:36:51 +0800 |
commit | 07d2ace8b4771e2ad48d4a9e6bf43a2022a25fac (patch) | |
tree | 8f76b7e3ce69ceb6d7822ec9aa8977a830d10c8d /rs422lib/rsbus.h | |
parent | d9c0c179fc4636b8927dd2c8b2cb29d573094731 (diff) | |
download | rsbus-07d2ace8b4771e2ad48d4a9e6bf43a2022a25fac.tar.gz rsbus-07d2ace8b4771e2ad48d4a9e6bf43a2022a25fac.tar.bz2 rsbus-07d2ace8b4771e2ad48d4a9e6bf43a2022a25fac.zip |
Added SYSSTOP & MSTATE macro
New example main.c
Diffstat (limited to 'rs422lib/rsbus.h')
-rw-r--r-- | rs422lib/rsbus.h | 130 |
1 files changed, 67 insertions, 63 deletions
diff --git a/rs422lib/rsbus.h b/rs422lib/rsbus.h index 2e29b9b..1297d72 100644 --- a/rs422lib/rsbus.h +++ b/rs422lib/rsbus.h @@ -1,63 +1,67 @@ -/*
- * rsbus.h
- *
- * Created on: 2014-4-26
- * Author: Tuowen
- */
-
-// DE RSOUT.RSPIN HIGH ENABLE
-// RE LOW ENABLE -> ALWAYS ENABLE
-// RECEIVE QUERY -> Conditional FNC call
-// Process -> Output (Done in main program)
-// SMCLK set to 4MHZ
-
-
-#ifndef RSBUS_H_
-#define RSBUS_H_
-
-#include<msp430g2553.h>
-#include"precomp.h"
-
-// MAXIMUM length to be send
-#define RS_MAX (14)
-
-#define ST_BUSY (0x04)
-#define ST_RUN (0x02)
-#define ST_RES (0x01)
-#define ST_REST (0x00)
-
-// Switch the machine to a new state specified above
-// This will shown on the network -> must call
-#define SWITCH_STATE(STATE) (mac_stat[0]=STATE)
-
-// Changing the state value (unsigned char) ->
-// Available indices 0,1,2
-#define STATE(X) (mac_stat[X+1])
-
-// Start and Stop bits definition
-// Every message sent that does not agree with it will be ignored
-// Please avoid this pattern in STATE(X)
-#define STBIT0 (0x5B)
-#define STBIT1 (0xAD)
-#define EDBIT0 (0xA4)
-#define EDBIT1 (0x52)
-
-// Receieve handler ->
-// Received message and it's length
-typedef void (*rshdlr)(unsigned char* msg,unsigned int len);
-
-// RSBUS init function
-// Setting up UART, DE pin, receieve handler
-void rsbus_init(rshdlr);
-
-// Send something to the rs422 bus
-// Length must not exceeds RS_MAX
-void rsbus_w(int,unsigned char*,unsigned int);
-
-// Machine status -> change it to change the auto respond status
-// 0 is reserved for machine state specification
-// 1-3 used for mac_type specific state
-// recommend using SWITCH_STATE & STATE
-extern volatile unsigned char mac_stat[4];
-
-#endif /* RSBUS_H_ */
+/* + * rsbus.h + * + * Created on: 2014-4-26 + * Author: Tuowen + */ + +// DE RSOUT.RSPIN HIGH ENABLE +// RE LOW ENABLE -> ALWAYS ENABLE +// RECEIVE QUERY -> Conditional FNC call +// Process -> Output (Done in main program) +// SMCLK set to 4MHZ + + +#ifndef RSBUS_H_ +#define RSBUS_H_ + +#include<msp430g2553.h> +#include"precomp.h" + +// MAXIMUM length to be send +#define RS_MAX (14) + +#define ST_BUSY (0x04) +#define ST_RUN (0x02) +#define ST_RES (0x01) +#define ST_REST (0x00) + +// Switch the machine to a new state specified above +// This will shown on the network -> must call +#define SWITCH_STATE(STATE) (mac_stat[0]=STATE) +#define MSTATE (mac_stat[0]) + +// Changing the state value (unsigned char) -> +// Available indices 0,1,2 +#define STATE(X) (mac_stat[X+1]) + +// Return current mac state +#define RETSTATE (rsbus_w(0,(unsigned char*)mac_stat,4)) + +// Start and Stop bits definition +// Every message sent that does not agree with it will be ignored +// Please avoid this pattern in STATE(X) +#define STBIT0 (0x5B) +#define STBIT1 (0xAD) +#define EDBIT0 (0xA4) +#define EDBIT1 (0x52) + +// Receieve handler -> +// Received message and it's length +typedef void (*rshdlr)(unsigned char* msg,unsigned int len); + +// RSBUS init function +// Setting up UART, DE pin, receieve handler +void rsbus_init(rshdlr); + +// Send something to the rs422 bus +// Length must not exceeds RS_MAX +void rsbus_w(int,unsigned char*,unsigned int); + +// Machine status -> change it to change the auto respond status +// 0 is reserved for machine state specification +// 1-3 used for mac_type specific state +// recommend using SWITCH_STATE & STATE +extern volatile unsigned char mac_stat[4]; + +#endif /* RSBUS_H_ */ |