Petit Modbus 2.0
Loading...
Searching...
No Matches
PetitModbus.c
Go to the documentation of this file.
1
7#include "PetitModbus.h"
8
9
10#define PETITMODBUS_READ_COILS (1)
11#define PETITMODBUS_READ_DISCRETE_INPUTS (2)
12#define PETITMODBUS_READ_HOLDING_REGISTERS (3)
13#define PETITMODBUS_READ_INPUT_REGISTERS (4)
14#define PETITMODBUS_WRITE_SINGLE_COIL (5)
15#define PETITMODBUS_WRITE_SINGLE_REGISTER (6)
16#define PETITMODBUS_WRITE_MULTIPLE_COILS (15)
17#define PETITMODBUS_WRITE_MULTIPLE_REGISTERS (16)
18
20#define PETIT_FALSE_FUNCTION (0)
21#define PETIT_FALSE_SLAVE_ADDRESS (1)
22#define PETIT_DATA_NOT_READY (2)
23#define PETIT_DATA_READY (3)
24
25#define PETIT_ERROR_CODE_01 (0x01) // Function code is not supported
26#define PETIT_ERROR_CODE_02 (0x02) // Register address is not allowed or write-protected
27#define PETIT_ERROR_CODE_03 (0X03) // Third field incorrect
28#define PETIT_ERROR_CODE_04 (0x04) // Fourth or subsequent field incorrect
29
30#define PETIT_BUF_FN_CODE_I (1)
31#define PETIT_BUF_BYTE_CNT_I (6)
36#define PETIT_BUF_DAT_M(Idx) (((pu16_t)(PetitBuffer[2*(Idx) + 2]) << 8) \
37 | (pu16_t) (PetitBuffer[2*(Idx) + 3]))
38
39
43// of the two, PetitBufI is used more for RX validation and TX
44// PetitBufJ is used more for internal processing
47
49
51
53
63{
64 PetitBufI = 0;
65 Petit_Ptr = &(PetitBuffer[0]);
67 return;
68}
69
76{
79 {
80 *Petit_Ptr++ = rcvd;
81 PetitBufI++;
83 return 0;
84 }
85 return 1;
86}
87
95{
97 {
98 if (PetitBufI != 0)
99 {
100 *tx = *Petit_Ptr++;
101 PetitBufI--;
102 return 1;
103 }
104 else
105 {
106 // transmission complete. return to receive mode.
107 // the direction pin is handled by the porting code
109 Petit_Ptr = &(PetitBuffer[0]);
110 // PetitBufI is already set at 0 at this point
111 PetitLedOff();
112 return 0;
113 }
114 }
115 return 0;
116}
117
125#if PETIT_CRC == PETIT_CRC_TABULAR
126void Petit_CRC16_Calc(const pu16_t Data)
127{
128 Petit_CRC16 = (Petit_CRC16 >> 8) ^
129 PetitCRCtable[(Petit_CRC16 ^ (Data)) & 0xFF];
130 return;
131}
132#elif PETIT_CRC == PETIT_CRC_BITWISE
133void Petit_CRC16_Calc(const pu16_t Data)
134{
135 pu8_t i;
136
138 for (i = 8; i > 0; i--)
139 {
140 if (Petit_CRC16 & 0x0001)
141 Petit_CRC16 = (Petit_CRC16 >> 1) ^ 0xA001;
142 else
143 Petit_CRC16 >>= 1;
144 }
145}
146#elif PETIT_CRC == PETIT_CRC_EXTERNAL
147#define Petit_CRC16_Calc(Data) PetitPortCRC16Calc((Data), &Petit_CRC16)
148#else
149#error "No Valid CRC Algorithm!"
150#endif
151
158{
159 PetitBufI = 0;
161
162 return true;
163}
164
165
173{
174 // Initialise the output buffer. The first byte in the buffer says how many registers we have read
176 PetitBuffer[2] = ErrorCode;
177 PetitBufJ = 3;
180}
181
182
187#if PETITMODBUS_READ_COILS_ENABLED > 0
188void HandlePetitModbusReadCoils(void)
189{
190 pu16_t Petit_StartCoil = 0;
191 pu16_t Petit_NumberOfCoils = 0;
192 pu16_t Petit_i = 0;
193
194 // The message contains the requested start address and number of registers
195 Petit_StartCoil = PETIT_BUF_DAT_M(0);
196 Petit_NumberOfCoils = PETIT_BUF_DAT_M(1);
197
198 // If it is bigger than RegisterNumber return error to Modbus Master
199 // there is an interesting calculation done with the number of coils here
200 // since the first coil in a byte starts a new byte, we add seven to the
201 // number of coils.
202 // the left shift by three is a method of dividing by eight (2^3) without
203 // specifically using the divide function because divisions are expensive
204 // the number of registers in buffer are multiplied by two since each
205 // register in modbus is 16 bits
206 if ((Petit_StartCoil + Petit_NumberOfCoils)
207 > NUMBER_OF_COILS ||
208 Petit_NumberOfCoils + 7 >> 3 > NUMBER_OF_REGISTERS_IN_BUFFER * 2 ||
209 Petit_NumberOfCoils == 0)
210 {
212 }
213 else
214 {
215 pu8_t Petit_CurrentData = 0;
216 // Initialize the output buffer.
217 // The first byte in the PDU says how many bytes are in response
218 PetitBufJ = 2; // at least three bytes are in response.
219 // set less here to accommodate the following loop
220 PetitBuffer[2] = 0;
221
222 for (Petit_i = 0; Petit_i < Petit_NumberOfCoils; Petit_i++)
223 {
224 pu8_t Petit_CurrentBit;
225 if ((Petit_i & 7) == 0)
226 {
227 PetitBuffer[PetitBufJ++] = Petit_CurrentData;
228 Petit_CurrentData = 0;
229 }
230#if defined(PETIT_COIL) && \
231 (PETIT_COIL == PETIT_INTERNAL || PETIT_COIL == PETIT_BOTH)
232 // test the current coil bit
233 Petit_CurrentBit =
234 (PetitCoils[Petit_StartCoil + Petit_i >> 3]
235 & 1 << (Petit_StartCoil + Petit_i & 7)) != 0;
236 Petit_CurrentData |= (pu8_t) Petit_CurrentBit << (Petit_i & 7);
237#endif
238#if defined(PETIT_COIL) && \
239 (PETIT_COIL == PETIT_EXTERNAL || PETIT_COIL == PETIT_BOTH)
240 if (!PetitPortCoilRead(Petit_StartCoil + Petit_i,
241 &Petit_CurrentBit))
242 {
244 return;
245 }
246 Petit_CurrentData |= (pu8_t) (Petit_CurrentBit != 0) << (Petit_i & 7);
247#endif
248 }
249 PetitBuffer[PetitBufJ++] = Petit_CurrentData;
250 PetitBuffer[2] = PetitBufJ - 3;
251 PetitLedSuc();
253 }
254}
255#endif
256
261#if PETITMODBUS_READ_HOLDING_REGISTERS_ENABLED > 0
262void HandlePetitModbusReadHoldingRegisters(void)
263{
264 // Holding registers are effectively numerical outputs that can be written to by the host.
265 // They can be control registers or analogue outputs.
266 // We potentially have one - the pwm output value
267 pu16_t Petit_StartAddress = 0;
268 pu16_t Petit_NumberOfRegisters = 0;
269 pu16_t Petit_i = 0;
270
271 // The message contains the requested start address and number of registers
272 Petit_StartAddress = PETIT_BUF_DAT_M(0);
273 Petit_NumberOfRegisters = PETIT_BUF_DAT_M(1);
274
275 // If it is bigger than RegisterNumber return error to Modbus Master
276 if ((Petit_StartAddress + Petit_NumberOfRegisters)
278 Petit_NumberOfRegisters > NUMBER_OF_REGISTERS_IN_BUFFER)
280 else
281 {
282 // Initialise the output buffer.
283 // The first byte in the PDU says how many registers we have read
284 PetitBufJ = 3;
285 PetitBuffer[2] = 0;
286
287 for (Petit_i = 0; Petit_i < Petit_NumberOfRegisters; Petit_i++)
288 {
289 pu16_t Petit_CurrentData;
290#if defined(PETIT_REG) && \
291 (PETIT_REG == PETIT_INTERNAL || PETIT_REG == PETIT_BOTH)
292 Petit_CurrentData = PetitRegisters[Petit_StartAddress
293 + Petit_i];
294#endif
295#if defined(PETIT_REG) && PETIT_REG == PETIT_EXTERNAL
296 if (!PetitPortRegRead(Petit_StartAddress + Petit_i, &Petit_CurrentData))
297 {
299 return;
300 }
301#endif
303 (pu8_t) ((Petit_CurrentData & 0xFF00) >> 8);
305 (pu8_t) (Petit_CurrentData & 0xFF);
306 PetitBufJ += 2;
307 }
308 PetitBuffer[2] = PetitBufJ - 3;
309 PetitLedSuc();
311 }
312}
313#endif
314
322#if PETITMODBUS_READ_INPUT_REGISTERS_ENABLED > 0
323void HandlePetitModbusReadInputRegisters(void)
324{
325 pu16_t Petit_StartAddress = 0;
326 pu16_t Petit_NumberOfRegisters = 0;
327 pu16_t Petit_i = 0;
328
329 // The message contains the requested start address and number of registers
330 Petit_StartAddress = PETIT_BUF_DAT_M(0);
331 Petit_NumberOfRegisters = PETIT_BUF_DAT_M(1);
332
333 // If it is bigger than RegisterNumber return error to Modbus Master
334 if ((Petit_StartAddress + Petit_NumberOfRegisters)
336 Petit_NumberOfRegisters > NUMBER_OF_REGISTERS_IN_BUFFER)
338 else
339 {
340 // Initialise the output buffer.
341 // The first byte in the PDU says how many registers we have read
342 PetitBufJ = 3;
343 PetitBuffer[2] = 0;
344
345 for (Petit_i = 0; Petit_i < Petit_NumberOfRegisters; Petit_i++)
346 {
347 pu16_t Petit_CurrentData;
348#if defined(PETIT_INPUT_REG) && \
349 (PETIT_INPUT_REG == PETIT_INTERNAL ||\
350 PETIT_INPUT_REG == PETIT_BOTH)
351 Petit_CurrentData = PetitInputRegisters[Petit_StartAddress
352 + Petit_i];
353#endif
354#if defined(PETIT_INPUT_REG) && PETIT_INPUT_REG == PETIT_EXTERNAL
355 if (!PetitPortInputRegRead(Petit_StartAddress + Petit_i, &Petit_CurrentData))
356 {
358 return;
359 }
360#endif
362 (pu8_t) ((Petit_CurrentData & 0xFF00) >> 8);
364 (pu8_t) (Petit_CurrentData & 0xFF);
365 PetitBufJ += 2;
366 }
367 PetitBuffer[2] = PetitBufJ - 3;
368 PetitLedSuc();
370 }
371}
372#endif
373
378#if PETITMODBUS_WRITE_SINGLE_COIL_ENABLED > 0
379void HandlePetitModbusWriteSingleCoil(void)
380{
381 // Write single numerical output
382 pu16_t Petit_Address = 0;
383 pu16_t Petit_Value = 0;
384 pu8_t Petit_i = 0;
385
386 // The message contains the requested start address and number of registers
387 Petit_Address = PETIT_BUF_DAT_M(0);
388 Petit_Value = PETIT_BUF_DAT_M(1);
389
390 // Initialise the output buffer. The first byte in the buffer says how many registers we have read
391 PetitBufJ = 6;
392
393 if (Petit_Address >= NUMBER_OF_COILS)
395 else if (Petit_Value != 0x0000 && Petit_Value != 0xFF00)
397 else
398 {
399#if defined(PETIT_COIL) && \
400 (PETIT_COIL == PETIT_INTERNAL || PETIT_COIL == PETIT_BOTH)
401 if (Petit_Value)
402 PetitCoils[Petit_Address >> 3] |= 1 << (Petit_Address & 7u);
403 else
404 PetitCoils[Petit_Address >> 3] &= ~(1 << (Petit_Address & 7u));
405#endif
406#if defined(PETIT_COIL) && PETIT_COIL == PETIT_EXTERNAL
407 if(!PetitPortCoilWrite(Petit_Address, Petit_Value))
408 {
410 return;
411 }
412#endif
413 // Output data buffer is exact copy of input buffer
414 }
415 PetitLedSuc();
417
418}
419#endif
420
425#if PETITMODBUS_WRITE_SINGLE_REGISTER_ENABLED > 0
426void HandlePetitModbusWriteSingleRegister(void)
427{
428 // Write single numerical output
429 pu16_t Petit_Address = 0;
430 pu16_t Petit_Value = 0;
431 pu8_t Petit_i = 0;
432
433 // The message contains the requested start address and number of registers
434 Petit_Address = PETIT_BUF_DAT_M(0);
435 Petit_Value = PETIT_BUF_DAT_M(1);
436
437 // Initialise the output buffer. The first byte in the buffer says how many registers we have read
438 PetitBufJ = 6;
439
440 if (Petit_Address >= NUMBER_OF_PETITREGISTERS)
442 else
443 {
444 PetitRegChange = 1;
445#if defined(PETIT_REG) && \
446 (PETIT_REG == PETIT_INTERNAL || PETIT_REG == PETIT_BOTH)
447 PetitRegisters[Petit_Address] = Petit_Value;
448#endif
449#if defined(PETIT_REG) && PETIT_REG == PETIT_EXTERNAL
450 if(!PetitPortRegWrite(Petit_Address, Petit_Value))
451 {
453 return;
454 }
455#endif
456 // Output data buffer is exact copy of input buffer
457 }
458 PetitLedSuc();
460}
461#endif
462
463
468#if PETITMODBUS_WRITE_MULTIPLE_COILS_ENABLED > 0
469void HandlePetitModbusWriteMultipleCoils(void)
470{
471 // Write single numerical output
472 pu16_t Petit_StartCoil = 0;
473 pu8_t Petit_ByteCount = 0;
474 pu16_t Petit_NumberOfCoils = 0;
475 pu16_t Petit_i = 0;
476 pu8_t Petit_CurrentBit = 0;
477
478 // The message contains the requested start address and number of registers
479 Petit_StartCoil = PETIT_BUF_DAT_M(0);
480 Petit_NumberOfCoils = PETIT_BUF_DAT_M(1);
481 Petit_ByteCount = PetitBuffer[PETIT_BUF_BYTE_CNT_I];
482
483 // If it is bigger than RegisterNumber return error to Modbus Master
484 if ((Petit_StartCoil + Petit_NumberOfCoils)
487 else if (Petit_NumberOfCoils > (255 - 9) * 8 || Petit_NumberOfCoils == 0)
489 else
490 {
491 // Initialise the output buffer. The first byte in the buffer says how many outputs we have set
492 PetitBufJ = 6;
493
494 // Output data buffer is exact copy of input buffer
495 for (Petit_i = 0; Petit_i < Petit_NumberOfCoils; Petit_i++)
496 {
497 // 7 is the index beyond the header for the function
498 Petit_CurrentBit = (PetitBuffer[(Petit_i >> 3) + 7]
499 & 1 << (Petit_i & 7))
500 != 0;
501#if defined(PETIT_REG) && \
502 (PETIT_REG == PETIT_INTERNAL || PETIT_REG == PETIT_BOTH)
503 if (Petit_CurrentBit)
504 PetitCoils[Petit_StartCoil + Petit_i >> 3] |=
505 1 << (Petit_StartCoil + Petit_i & 7);
506 else
507 PetitCoils[Petit_StartCoil + Petit_i >> 3] &=
508 ~(1 << (Petit_StartCoil + Petit_i & 7));
509#endif
510#if defined(PETIT_REG) && PETIT_REG == PETIT_EXTERNAL
511 if (!PetitPortCoilWrite(Petit_StartCoil + Petit_i, Petit_CurrentBit))
512 {
514 return;
515 }
516#endif
517 }
518 PetitLedSuc();
520 }
521}
522#endif
523
528#if PETITMODBUS_WRITE_MULTIPLE_REGISTERS_ENABLED > 0
529void HandlePetitModbusWriteMultipleRegisters(void)
530{
531 // Write single numerical output
532 pu16_t Petit_StartAddress = 0;
533 pu8_t Petit_ByteCount = 0;
534 pu16_t Petit_NumberOfRegisters = 0;
535 pu8_t Petit_i = 0;
536 pu16_t Petit_Value = 0;
537
538 // The message contains the requested start address and number of registers
539 Petit_StartAddress = PETIT_BUF_DAT_M(0);
540 Petit_NumberOfRegisters = PETIT_BUF_DAT_M(1);
541 Petit_ByteCount = PetitBuffer[PETIT_BUF_BYTE_CNT_I];
542
543 // If it is bigger than RegisterNumber return error to Modbus Master
544 if ((Petit_StartAddress + Petit_NumberOfRegisters)
547 else
548 {
549 // Initialise the output buffer. The first byte in the buffer says how many outputs we have set
550 PetitBufJ = 6;
551 PetitRegChange = 1;
552
553 // Output data buffer is exact copy of input buffer
554 for (Petit_i = 0; Petit_i < Petit_NumberOfRegisters; Petit_i++)
555 {
556 // 7 is the index beyond the header for the function
557 Petit_Value = (PetitBuffer[2*Petit_i + 7] << 8)
558 | (PetitBuffer[2*Petit_i + 8]);
559#if defined(PETIT_REG) && \
560 (PETIT_REG == PETIT_INTERNAL || PETIT_REG == PETIT_BOTH)
561 PetitRegisters[Petit_StartAddress + Petit_i] = Petit_Value;
562#endif
563#if defined(PETIT_REG) && PETIT_REG == PETIT_EXTERNAL
564 if (!PetitPortRegWrite(Petit_StartAddress + Petit_i, Petit_Value))
565 {
567 return;
568 }
569#endif
570 }
571 PetitLedSuc();
573 }
574}
575#endif
576
577
587{
589 {
591 }
592
593 if (PetitBufI > 6 && PetitExpectedReceiveCount == 0)
594 {
596 && PetitBuffer[PETIT_BUF_FN_CODE_I] <= 0x06) // RHR
597 {
599 }
600 else if (PetitBuffer[PETIT_BUF_FN_CODE_I] == 0x0F
602 {
605 {
607 }
608 }
609 else
610 {
612 }
613 }
614
617 {
618 return PETIT_DATA_READY;
619 }
620
622}
623
624
630void Petit_RxRTU(void)
631{
632 pu8_t Petit_i;
633 pu8_t Petit_ReceiveBufferControl = 0;
634 Petit_ReceiveBufferControl = CheckPetitModbusBufferComplete();
635
636 if (Petit_ReceiveBufferControl == PETIT_DATA_READY)
637 {
638 // disable timeout
640
641 // CRC calculate
642 Petit_CRC16 = 0xFFFF;
643 // subtract two to skip the CRC in the ADU
645 for (Petit_i = 0; Petit_i < PetitBufJ; ++Petit_i)
646 {
648 }
649
653 + 1] << 8)) == Petit_CRC16)
654 {
655 // Valid message!
657 }
658 else
659 {
662 }
663 }
664}
665
666
672void Petit_TxRTU(void)
673{
674 Petit_CRC16 = 0xFFFF;
675 for (PetitBufI = 0; PetitBufI < PetitBufJ;
676 PetitBufI++)
677 {
679 }
680
683
684 Petit_Ptr = &(PetitBuffer[0]);
685
686 Petit_Tx_Delay = 0;
688}
689
697{
698 // Data is for us but which function?
700 {
701#if PETITMODBUS_READ_COILS_ENABLED > 0
703 HandlePetitModbusReadCoils();
704 break;
705#endif
706#if PETITMODBUS_READ_HOLDING_REGISTERS_ENABLED > 0
708 HandlePetitModbusReadHoldingRegisters();
709 break;
710#endif
711#if PETITMODBUS_READ_INPUT_REGISTERS_ENABLED > 0
713 HandlePetitModbusReadInputRegisters();
714 break;
715#endif
716#if PETITMODBUS_WRITE_SINGLE_COIL_ENABLED > 0
718 HandlePetitModbusWriteSingleCoil();
719 break;
720#endif
721#if PETITMODBUS_WRITE_SINGLE_REGISTER_ENABLED > 0
723 HandlePetitModbusWriteSingleRegister();
724 break;
725#endif
726#if PETITMODBUS_WRITE_MULTIPLE_COILS_ENABLED > 0
728 HandlePetitModbusWriteMultipleCoils();
729 break;
730#endif
731#if PETITMODBUS_WRITE_MULTIPLE_REGISTERS_ENABLED > 0
733 HandlePetitModbusWriteMultipleRegisters();
734 break;
735#endif
736 default:
738 break;
739 }
740 return;
741}
742
743
751{
752 switch (Petit_RxTx_State)
753 {
754#if PETITMODBUS_PROCESS_POSITION >= 1
757 // no break here. Position 1 blends processing with TxRTU.
758#endif
759 case PETIT_RXTX_TX_DATABUF: // if the answer is ready, send it
760 Petit_TxRTU();
761 // no break here. TxRTU always exits in a correct state.
763 // process the TX delay
765 {
767 }
768 else
769 {
770 // print first character to start UART peripheral
773 PetitBufI--;
774 }
775 break;
776 case PETIT_RXTX_TX:
777 // no work is done here. wait until transmission completes.
778 break;
779 // position 0 has the RX process on its own.
780#if PETITMODBUS_PROCESS_POSITION <= 0
783 break;
784#endif
785 default:
786 Petit_RxRTU();
787 break;
788 }
789}
790
791
792#if !defined(PETIT_COIL) || (PETIT_COIL != PETIT_INTERNAL && \
793 PETIT_COIL != PETIT_BOTH && PETIT_COIL != PETIT_EXTERNAL)
794#error "PETIT_COIL not defined or not valid."
795#endif
796
797#if !defined(PETIT_REG) || (PETIT_REG != PETIT_INTERNAL && \
798 PETIT_REG != PETIT_BOTH && PETIT_REG != PETIT_EXTERNAL)
799#error "PETIT_REG not defined or not valid."
800#endif
801
802#if !defined(PETIT_INPUT_REG) || (PETIT_INPUT_REG != PETIT_INTERNAL && \
803 PETIT_INPUT_REG != PETIT_BOTH && PETIT_INPUT_REG != PETIT_EXTERNAL)
804#error "PETTI_INPUT_REG not defined or not valid."
805#endif
PETIT_CODE const pu16_t PetitCRCtable[256]
#define PETITMODBUS_READ_HOLDING_REGISTERS
Definition PetitModbus.c:12
#define PETITMODBUS_WRITE_SINGLE_COIL
Definition PetitModbus.c:14
#define PETIT_FALSE_FUNCTION
Definition PetitModbus.c:20
#define PETITMODBUS_READ_COILS
Definition PetitModbus.c:10
pu8_t PetitBuffer[PETITMODBUS_RXTX_BUFFER_SIZE]
Definition PetitModbus.c:41
pu16_t PetitExpectedReceiveCount
Definition PetitModbus.c:52
void HandlePetitModbusError(pu8_t ErrorCode)
void Petit_CRC16_Calc(const pu16_t Data)
#define PETIT_ERROR_CODE_02
Definition PetitModbus.c:26
#define PETIT_DATA_NOT_READY
Definition PetitModbus.c:22
pb_t PetitRxBufferInsert(pu8_t rcvd)
Definition PetitModbus.c:75
pb_t PetitTxBufferPop(pu8_t *tx)
Definition PetitModbus.c:94
void Petit_ResponseProcess(void)
PETIT_RXTX_STATE Petit_RxTx_State
Definition PetitModbus.c:40
#define PETIT_BUF_DAT_M(Idx)
Definition PetitModbus.c:36
pu16_t Petit_CRC16
Definition PetitModbus.c:42
void ProcessPetitModbus(void)
pu8_t * Petit_Ptr
Definition PetitModbus.c:48
#define PETITMODBUS_WRITE_MULTIPLE_COILS
Definition PetitModbus.c:16
#define PETIT_ERROR_CODE_01
Definition PetitModbus.c:25
#define PETIT_ERROR_CODE_04
Definition PetitModbus.c:28
#define PETIT_DATA_READY
Definition PetitModbus.c:23
void Petit_RxRTU(void)
pu8_t CheckPetitModbusBufferComplete(void)
#define PETIT_ERROR_CODE_03
Definition PetitModbus.c:27
#define PETITMODBUS_WRITE_SINGLE_REGISTER
Definition PetitModbus.c:15
pb_t PetitSendMessage(void)
void PetitRxBufferReset()
Definition PetitModbus.c:62
pu16_t Petit_Tx_Delay
Definition PetitModbus.c:50
#define PETIT_BUF_BYTE_CNT_I
Definition PetitModbus.c:31
pu16_t PetitBufI
Definition PetitModbus.c:45
#define PETITMODBUS_READ_INPUT_REGISTERS
Definition PetitModbus.c:13
void Petit_TxRTU(void)
pu16_t PetitBufJ
Definition PetitModbus.c:46
#define PETIT_BUF_FN_CODE_I
Definition PetitModbus.c:30
#define PETIT_FALSE_SLAVE_ADDRESS
Definition PetitModbus.c:21
#define PETITMODBUS_WRITE_MULTIPLE_REGISTERS
Definition PetitModbus.c:17
PETIT_RXTX_STATE
Definition PetitModbus.h:26
@ PETIT_RXTX_RX
Definition PetitModbus.h:27
@ PETIT_RXTX_TX_DLY
Definition PetitModbus.h:30
@ PETIT_RXTX_PROCESS
Definition PetitModbus.h:28
@ PETIT_RXTX_TX
Definition PetitModbus.h:31
@ PETIT_RXTX_TX_DATABUF
Definition PetitModbus.h:29
#define PETITMODBUS_RXTX_BUFFER_SIZE
Definition PetitModbus.h:19
#define PetitLedErrFail()
#define PetitLedCrcFail()
#define PetitLedSuc()
#define PetitLedOff()
unsigned char PetitRegChange
Definition PetitReg.c:47
#define pu16_t
uint8_t PETITMODBUS_SLAVE_ADDRESS
pb_t PetitPortCoilRead(pu16_t Address, pu8_t *Data)
#define NUMBER_OF_PETITREGISTERS
void PetitPortTimerStart(void)
pb_t PetitPortCoilWrite(pu16_t Address, pu16_t Data)
#define NUMBER_OF_COILS
pb_t PetitPortRegWrite(pu8_t Address, pu16_t Data)
uint8_t PETITMODBUS_DLY_TOP
pb_t PetitPortRegRead(pu8_t Address, pu16_t *Data)
#define NUMBER_OF_INPUT_PETITREGISTERS
#define pu8_t
void PetitPortTxBegin(pu8_t tx)
#define NUMBER_OF_REGISTERS_IN_BUFFER
void PetitPortTimerStop(void)
#define pb_t