SMBus Library for MSP430G2xx3 Devices  1.10.00.00
 All Data Structures Functions Variables Enumerations Enumerator Modules Pages
smbus.h
1 #ifndef __SMBUS_H__
2 #define __SMBUS_H__
3 
4 //*****************************************************************************
5 //
6 //! \addtogroup smbus Application API layer
7 //! @{
8 //
9 //*****************************************************************************
10 
11 //*****************************************************************************
12 //
13 // If building with a C++ compiler, make all of the definitions in this header
14 // have a C binding.
15 //
16 //*****************************************************************************
17 #ifdef __cplusplus
18 extern "C"
19 {
20 #endif
21 
22 //
23 // Include files
24 //
25 #include <stdlib.h>
26 #include <stdint.h>
27 #include <stdbool.h>
28 
29 //*****************************************************************************
30 // defines
31 //*****************************************************************************
32 
33 //*****************************************************************************
34 //
35 //! Define to support Packet Error Checking (PEC)
36 //
37 //*****************************************************************************
38 #define SMB_PEC_SUPPORTED (1)
39 
40 //*****************************************************************************
41 //
42 //! Define to enable Manual ACK workaround
43 //
44 //! The MSP403 eUSCI doesn't support tesing a received byte and NACK/ACK immediately.
45 //! This workaround uses DMA to stretch SCL low immediately after a byte is
46 //! received. The DMA ISR is attended and the application then decides if it
47 //! needs to ACK or NACK the byte
48 //
49 //! This capability is not supported on devices that do not have DMA (e.g.
50 //! MSP430G2xxx.
51 //
52 //*****************************************************************************
53 #define SMB_MANUAL_ACK_ENABLE (0)
54 
55 //*****************************************************************************
56 //
57 //! Define method used to calculate CRC8:
58 //! - \b SMB_CRC8_USE_LOOKUP_TABLE == 1 - Use a 256B lookup table (faster but
59 //! takes more memory)
60 //! - \b SMB_CRC8_USE_LOOKUP_TABLE == 0 - Calculate CRC8 manually (slower
61 //! but takes less memory)
62 //
63 //*****************************************************************************
64 #define SMB_CRC8_USE_LOOKUP_TABLE (1)
65 
66 //*****************************************************************************
67 //
68 //! Maximum payload as specified by SMBus Spec
69 //
70 //*****************************************************************************
71 #define SMB_MAX_PAYLOAD_SIZE (32)
72 
73 //*****************************************************************************
74 //
75 //! Max packet size = Payload+PEC+CMD+Len
76 //
77 //*****************************************************************************
78 #define SMB_MAX_PACKET_SIZE (SMB_MAX_PAYLOAD_SIZE + 3)
79 
80 //*****************************************************************************
81 //
82 //! Default response when there's nothing to send
83 //
84 //*****************************************************************************
85 #define RESPONSE_NTR 0x00
86 
87 //*****************************************************************************
88 //
89 //! Return value when successful
90 //
91 //*****************************************************************************
92 #define SMBUS_RET_OK (1)
93 
94 //*****************************************************************************
95 //
96 //! Return value when an error ocurred
97 //
98 //*****************************************************************************
99 #define SMBUS_RET_ERROR (-1)
100 
101 //*****************************************************************************
102 // typedefs
103 //*****************************************************************************
104 
105 //*****************************************************************************
106 //
107 //! List of stop codes used within the NWK and PHY layers
108 //
109 //*****************************************************************************
110 typedef enum
111 {
112  SMBus_Stop_No = 0, //! No Stop send
113  SMBus_Stop_Immediate, //! Stop is send immediately with Start
114  SMBus_Stop_Addr, //! Stop is send after Start
115  SMBus_Stop_PreRead, //! Stop sent before reading next byte
116  SMBus_Stop_Sent, //! Stop sent
117 } SMBus_Stop;
118 
119 //*****************************************************************************
120 //
121 //! SMBus control register
122 //
123 //*****************************************************************************
124 typedef union
125 {
126  //*****************************************************************************
127  //
128  //! Defines the control bit fields
129  //
130  //*****************************************************************************
131  struct
132  {
133  uint8_t pecEn : 1; //! Enables PEC functionality
134  uint8_t swackEn : 1; //! SW_ACK is enabled (read only)
135  uint8_t intEn : 1; //! Interupts are enabled (read only)
136  uint8_t phyEn : 1; //! SMBus PHY is enabled (read only)
137  uint8_t master : 1; //! Acting in Master mode (read only)
138  uint8_t reserved2 : 3; //! Reserved
139  } bits;
140  //*****************************************************************************
141  //
142  //! Allows access to the writeable bits on the structure
143  //
144  //*****************************************************************************
145  struct
146  {
147  uint8_t writeBits : 1; //! Control bits that are writable
148  uint8_t reserved : 7; //! Masks the read only control
149  } writeableBits;
150  //! Whole Control byte access
151  uint8_t u8byte;
152 } SMBus_Ctrl;
153 
154 //*****************************************************************************
155 //
156 //! Physical and Data Link Layer object
157 //
158 //*****************************************************************************
159 typedef struct
160 {
161  uint16_t SMBus_Phy_i2cBase; //! I2C Base address
162  SMBus_Stop SMBus_Phy_stop; //! Send different types of Stop as master
163 } SMBus_Phy;
164 
165 //*****************************************************************************
166 //
167 //! SMBus network layer states
168 //
169 //*****************************************************************************
170 typedef enum
171 {
172  SMBus_NwkState_Idle = 0, //! Network is idle and waiting for new packet
173  SMBus_NwkState_RX, //! Network is receiving a packet
174  SMBus_NwkState_TX, //! Network is transmitting after receive byte
175  SMBus_NwkState_TXQuickCMD, //! Network is sending Quick Command
176  SMBus_NwkState_TX_Resp, //! Network is transmitting a response after restart
177  SMBus_NwkState_TX_Block, //! Network is transmitting a block
178  SMBus_NwkState_RX_Block, //! Network is receiving a block
179  SMBus_NwkState_Ending, //! Network is finishing transfer
180  SMBus_NwkState_Error //! Network error detected
182 
183 //*****************************************************************************
184 //
185 //! Definition of SMBus Network structure
186 //
187 //*****************************************************************************
188 typedef struct
189 {
190  volatile SMBus_NwkState eState; //! Network state machine
191  uint8_t currentAddr; //! Current Address+R/W
192  uint8_t currentCmd; //! Current Command
193  uint8_t rxIndex; //! RX Byte counter
194  uint8_t rxLen; //! Bytes to receive
195  uint8_t rxSize; //! Max size of buffer
196  uint8_t *rxBuffPtr; //! Reception Buffer pointer
197  uint8_t txIndex; //! Byte counter
198  uint8_t txLen; //! Bytes to send
199  uint8_t *txBuffPtr; //! Transmission pointer
200  uint8_t *recByteTxPtr; //! Receive Byte response
201  uint8_t txSize; //! Max size of buffer
202 #if (SMB_PEC_SUPPORTED == 1)
203  uint8_t pec; //! Current PEC value
204 #endif
205 } SMBus_Nwk;
206 
207 //*****************************************************************************
208 //
209 //! List of error codes used by the application to indicate an error to the library
210 //
211 //*****************************************************************************
212 typedef enum
213 {
214  SMBus_ErrorCode_NoError = 0, //! No error detected
215  SMBus_ErrorCode_Packet, //! Incorrect packet was received
216  SMBus_ErrorCode_Cmd //! Command is not supported
218 
219 //*****************************************************************************
220 //
221 //! SMBus state sent to application layer
222 //
223 //*****************************************************************************
224 typedef enum
225 {
226  SMBus_State_OK = 0, //! Nothing special to report
227  SMBus_State_DataSizeError, //! Incorrect packet size
228  SMBus_State_PECError, //! PEC Error detected
229  SMBus_State_TimeOutError, //! Timeout Error
230  SMBus_State_Slave_FirstByte, //! 1st byte (cmd) received
231  SMBus_State_Slave_ByteReceived, //! Slave received a byte (2-n)
232  SMBus_State_Slave_QCMD, //! Quick Command detected
233  SMBus_State_Slave_CmdComplete, //! Complete packet received by slave
234  SMBus_State_Slave_Error, //! SMBus Slave Error
235  SMBus_State_Slave_NotReady, //! SMBus Buffers haven't been initialized
236  SMBus_State_Slave_NTR, //! No Interrupt flags detected
237  SMBus_State_Master_ArbLost, //! Arbitration Lost
238  SMBus_State_Master_NACK, //! Unexpected NACKed
239  SMBus_State_Master_Error, //! SMBus Master error
241 } SMBus_State;
242 
243 //*****************************************************************************
244 //
245 //! SMBus Status Register
246 //
247 //*****************************************************************************
248 typedef union
249 {
250  //*****************************************************************************
251  //
252  //! Status flag register
253  //
254  //*****************************************************************************
255  struct
256  {
257  uint8_t pecErr : 1; //! PEC error
258  uint8_t toErr : 1; //! Timeout error
259  uint8_t packErr : 1; //! Error in packet format
260  uint8_t packOvrErr : 1; //! Packet Overrun error
261  uint8_t byteOvrErr : 1; //! Byte Overrun error
262  uint8_t cmdErr : 1; //! Incorrect command
263  uint8_t reserved : 2; //! Reserved bits
264  } bits;
265  //! Whole status byte access
266  uint8_t u8byte;
267 } SMBus_Status;
268 
269 //*****************************************************************************
270 //
271 //! Main SMBus object
272 //
273 //*****************************************************************************
274 typedef struct
275 {
276  SMBus_Phy phy; //! PHY and DataLink object
277  SMBus_Nwk nwk; //! Network object
278  SMBus_Ctrl ctrl; //! SMBus Control register
279  SMBus_Status status; //! SMBus Status register
280  SMBus_State state; //! SMBus reported state
281  uint8_t ownSlaveAddr; //! Own Slave address
282 } SMBus;
283 
284 //*****************************************************************************
285 // globals
286 //*****************************************************************************
287 
288 //*****************************************************************************
289 // Public functions called by applications
290 //*****************************************************************************
291 //*****************************************************************************
292 //
293 //! \brief Clears the current state of SMBus
294 //
295 //! Must be called by application in order to clear the state machine
296 //! when a byte/packet was processed
297 //
298 //! \param smbus Pointer to SMBus structure
299 //
300 //! \return None
301 //
302 //*****************************************************************************
303 extern void SMBus_processDone(SMBus *smbus);
304 
305 //*****************************************************************************
306 //
307 //! \brief Returns the number of received bytes from last transaction
308 //
309 //! \param smbus Pointer to SMBus structure
310 //
311 //! \return Number of bytes in the RX buffer. PEC byte is *not* included.
312 //
313 //*****************************************************************************
314 extern uint8_t SMBus_getRxPayloadAvailable(SMBus *smbus);
315 
316 //*****************************************************************************
317 //
318 //! \brief Returns the state of the SMBus module
319 //
320 //! \param smbus Pointer to SMBus structure
321 //
322 //! \return State of the SMBus module
323 //
324 //*****************************************************************************
325 extern SMBus_State SMBus_getState(SMBus *smbus);
326 
327 #if (SMB_PEC_SUPPORTED == 1)
328 //*****************************************************************************
329 //
330 //! \brief Enables PEC support
331 //
332 //! \param smbus Pointer to SMBus structure
333 //
334 //! \return None
335 //
336 //*****************************************************************************
337 extern void SMBus_enablePEC(SMBus *smbus);
338 //*****************************************************************************
339 //
340 //! \brief Disables PEC support
341 //
342 //! \param smbus Pointer to SMBus structure
343 //
344 //! \return None
345 //
346 //*****************************************************************************
347 extern void SMBus_disablePEC(SMBus *smbus);
348 #endif
349 
350 //*****************************************************************************
351 //
352 //! \brief Initialize the SMBus interface as a slave
353 //
354 //! Initializes the NWK and PHY layers.
355 //
356 //! \param smbus Pointer to SMBus structure
357 //! \param i2cAddr Base address of I2C module. For MSP430G2xxx devices,
358 //! this parameter is ignored.
359 //
360 //! \return None
361 //
362 //*****************************************************************************
363 extern void SMBus_slaveInit(SMBus *smbus,
364  uint16_t i2cAddr);
365 
366 //*****************************************************************************
367 //
368 //! \brief Enables the I2C interrupts for a slave
369 //
370 //! This function enables the eUSCI Start,Stop, RX,TX, Timeout interrupts
371 //! If \b SMB_MANUAL_ACK_ENABLE is enabled, it enables DMA to handle the RX
372 //! SMBus_slaveInit() must be called before this function
373 //
374 //! \param smbus Pointer to SMBus structure
375 //
376 //! \return None
377 //
378 //*****************************************************************************
379 extern void SMBus_slaveEnableInt(SMBus *smbus);
380 
381 //*****************************************************************************
382 //
383 //! \brief I2C Interrupt Service routine for a slave
384 //
385 //! Handles the interrupts for SMBus passing information to NWK layer
386 //! Should be called by application when USCI/DMA interrupt is detected
387 //! Note that this routine also checks the DMA due to the SW ACK workaround if
388 //! \b SMB_MANUAL_ACK_ENABLE is defined.
389 //
390 //! \param smbus Pointer to SMBus structure
391 //
392 //! \return Processing State (SMBus_State)
393 //! - \b SMBus_State_Slave_NotReady - Packet is not ready
394 //! - \b SMBus_State_Slave_FirstByte - First byte received (application can use
395 //! it to validate the command)
396 //! - \b SMBus_State_Slave_ByteReceived - Byte 2+ received (application can use
397 //! it to validate each byte)
398 //! - \b SMBus_State_Slave_QCMD - Quick command received
399 //! - \b SMBus_State_Slave_CmdComplete - Packet complete and if PEC enabled,
400 //! validated.
401 //
402 //*****************************************************************************
404 
405 //*****************************************************************************
406 //
407 //! \brief Force reset to SMBus master interface
408 //
409 //! Resets the network and PHY layers
410 //
411 //! \param smbus Pointer to SMBus structure
412 //
413 //! \return None
414 //
415 //*****************************************************************************
416 extern void SMBus_masterReset(SMBus *smbus);
417 
418 #ifdef __MSP430_HAS_USCI__
419 //*****************************************************************************
420 //
421 //! \brief Timer interrupt service routine for slave application
422 //
423 //! Handles the interrupts for SMBus tiemout processing for USCI devices.
424 //! Should be called by application when Timer interrupt is detected
425 //
426 //! \param smbus Pointer to SMBus structure
427 //
428 //! \return Processing State (SMBus_State):
429 //! - \b SMBus_State_TimeOutError - Timeout ocurred, SMBUS has
430 //! been restarted
431 //
432 //*****************************************************************************
434 #endif
435 
436 //*****************************************************************************
437 //
438 //! \brief Set the slave's own I2C address
439 //
440 //! \param smbus Pointer to SMBus structure
441 //! \param slaveAddr Slave I2C address
442 //
443 //! \return None
444 //
445 //*****************************************************************************
446 extern void SMBus_slaveSetAddress(SMBus *smbus,
447  uint8_t slaveAddr);
448 
449 //*****************************************************************************
450 //
451 //! \brief Initialize the reception buffer for slave
452 //
453 //! \param smbus Pointer to SMBus structure
454 //! \param data Pointer to Application RX buffer
455 //! \param size Maximum size of buffer
456 //
457 //! \return None
458 //
459 //*****************************************************************************
460 extern void SMBus_slaveSetRxBuffer(SMBus *smbus,
461  uint8_t *data,
462  uint8_t size);
463 
464 //*****************************************************************************
465 //
466 //! \brief Initialize the transmission buffer for slave
467 //
468 //! \param smbus Pointer to SMBus structure
469 //! \param data Pointer to Application TX buffer
470 //! \param size Maximum size of buffer
471 //
472 //! \return None
473 //
474 //*****************************************************************************
475 extern void SMBus_slaveSetTxBuffer(SMBus *smbus,
476  uint8_t *data,
477  uint8_t size);
478 
479 //*****************************************************************************
480 //
481 //! \brief Reports an error to SMBus driver from the slave
482 //
483 //! Used to signal an error when incorrect command/data is detected by the slave
484 //
485 //! \param smbus Pointer to SMBus structure
486 //! \param errorCode SMBus_ErrorCode
487 //
488 //! \return None
489 //
490 //*****************************************************************************
491 extern void SMBus_slaveReportError(SMBus *smbus,
492  SMBus_ErrorCode errorCode);
493 
494 //*****************************************************************************
495 //
496 //! \brief Return the current command (Rxbuffer[0]) received by the slave
497 //
498 //! \param smbus Pointer to SMBus structure
499 //
500 //! \return Current command byte
501 //
502 //*****************************************************************************
503 extern uint8_t SMBus_slaveGetCommand(SMBus *smbus);
504 
505 //*****************************************************************************
506 //
507 //! \brief Clear the slave's status register
508 //
509 //! \param smbus Pointer to SMBus structure
510 //! \param val Bits cleared from status register (1=X, 0=clear)
511 //
512 //! \return Value of Status register after clearing flags
513 //
514 //*****************************************************************************
515 extern uint8_t SMBus_slaveClearStatusReg(SMBus *smbus,
516  uint8_t val);
517 
518 //*****************************************************************************
519 //
520 //! \brief Write a value to the slave's control register
521 //
522 //! \param smbus Pointer to SMBus structure
523 //! \param val Value being written to the Control register
524 //
525 //! \return Value of Control register after write
526 //
527 //*****************************************************************************
528 extern uint8_t SMBus_slaveWriteCtrlReg(SMBus *smbus,
529  uint8_t val);
530 
531 #if (SMB_MANUAL_ACK_ENABLE == 1)
532 //*****************************************************************************
533 //
534 //! \brief Enables functionality for the slave to perform manual ACK/NACK
535 //
536 //! DMA will be used to stretch SCL
537 //
538 //! \param smbus Pointer to SMBus structure
539 //
540 //! \return None
541 //
542 //*****************************************************************************
543 extern void SMBus_slaveEnableManualACK(SMBus *smbus);
544 //*****************************************************************************
545 //
546 //! \brief Disables functionality for the slave to perform manual ACK/NACK
547 //
548 //! \param smbus Pointer to SMBus structure
549 //
550 //! \return None
551 //
552 //*****************************************************************************
553 extern void SMBus_slaveDisableManualACK(SMBus *smbus);
554 
555 //*****************************************************************************
556 //
557 //! \brief Send the ACK/NACK from the slave
558 //
559 //! \param smbus Pointer to SMBus structure
560 //! \param sendAck if true, sends ACK. If false, sends NACK
561 //
562 //! \return None
563 //
564 //*****************************************************************************
565 extern void SMBus_slaveSendACK(SMBus *smbus,
566  bool sendAck);
567 #endif
568 
569 //*****************************************************************************
570 //
571 //! \brief Initialize the SMBus Interface for a master
572 //
573 //! Initializes the NWK and PHY layers
574 //
575 //! \param smbus Pointer to SMBus structure
576 //! \param i2cAddr Base address of I2C module. For MSP430G2xxx devices,
577 //! this parameter is ignored.
578 //! \param busClk SMCLK Frequency
579 //
580 // \return None
581 //
582 //*****************************************************************************
583 extern void SMBus_masterInit(SMBus *smbus,
584  uint16_t i2cAddr,
585  uint32_t busClk);
586 
587 //*****************************************************************************
588 //
589 //! \brief Enables the I2C interrupts for a master
590 //
591 //! This function enables the eUSCI Start,Stop, RX,TX, Timeout interrupts.
592 //! SMBus_masterInit() must be called before this function.
593 //! If \b SMB_MANUAL_ACK_ENABLE is enabled, it enables DMA to handle the RX.
594 //
595 //! \param smbus Pointer to SMBus structure
596 //
597 //! \return none
598 //
599 //*****************************************************************************
600 extern void SMBus_masterEnableInt(SMBus *smbus);
601 
602 //*****************************************************************************
603 //
604 //! \brief I2C Interrupt Service routine for a master
605 //
606 //! Handles the interrupts for SMBus passing information to NWK layer
607 //! Should be called by application when USCI interrupt is detected
608 //
609 //! \param smbus Pointer to SMBus structure
610 //
611 //! \return Processing State (SMBus_State)
612 //
613 //*****************************************************************************
615 
616 #ifdef __MSP430_HAS_USCI__
617 //*****************************************************************************
618 //
619 //! \brief Timer interrupt service routine for a master
620 //
621 //! Handles the interrupts for SMBus tiemout processing for USCI devices.
622 //! Should be called by application when Timer interrupt is detected
623 //
624 //! \param smbus Pointer to SMBus structure
625 //
626 //! \return Processing State (SMBus_State):
627 //
628 //*****************************************************************************
630 #endif
631 
632 //*****************************************************************************
633 //
634 //! \brief Sends a process call to a slave
635 //
636 //! Send process call to the slave. A command byte and 2 bytes of TX data are
637 //! required. Two bytes of data will be returned by the slave in rxData.
638 //!
639 //!~~~~~~~~
640 //! SMBus Process Call command protocol
641 //!
642 //! Process Call:
643 //! 1 7 1 1 8 1 8 1 8 1
644 //! ------------------------------------------------------------------------------------------
645 //! | S | Slave Address | Wr | A | Command Code | A | Data Byte Low | A | Data Byte High | A | ...
646 //! ------------------------------------------------------------------------------------------
647 //! 1 7 1 1 8 1 8 1 1
648 //! ----------------------------------------------------------------------------
649 //! | Sr | Slave Address | Rd | A | Data Byte Low | A | Data Byte High | A | P |
650 //! ----------------------------------------------------------------------------
651 //! Process Call with PEC:
652 //! 1 7 1 1 8 1 8 1 8 1
653 //! ------------------------------------------------------------------------------------------
654 //! | S | Slave Address | Wr | A | Command Code | A | Data Byte Low | A | Data Byte High | A | ...
655 //! ------------------------------------------------------------------------------------------
656 //! 1 7 1 1 8 1 8 1 8 1 1
657 //! --------------------------------------------------------------------------------------
658 //! | Sr | Slave Address | Rd | A | Data Byte Low | A | Data Byte High | A | PEC | A | P |
659 //! --------------------------------------------------------------------------------------
660 //!
661 //! where:
662 //! S = Start bit
663 //! Sr = Reapeated Start bit
664 //! Wr = Write bit (0)
665 //! Slave Adddress = SMBus address for slave
666 //! Command Code = Command byte sent to slave
667 //! Data Byte = data sent to slave
668 //! A = Acknowledge from slave
669 //! PEC = Optional Packet Error Code
670 //! P = Stop bit
671 //!~~~~~~~~
672 //
673 //! \param smbus Pointer to SMBus structure
674 //! \param targetAddr Slave address
675 //! \param command Command byte for slave
676 //! \param txData TX data buffer
677 //! \param rxData RX data buffer
678 //
679 //! \return \b SMBUS_RET_ERROR, or \b SMBUS_RET_OK
680 //
681 //*****************************************************************************
682 extern int8_t SMBus_masterProcessCall(SMBus *smbus,
683  uint8_t targetAddr,
684  uint8_t command,
685  uint8_t *txData,
686  uint8_t *rxData);
687 
688 //*****************************************************************************
689 //
690 //! \brief Sends a block write-block read process call
691 //
692 //! Send block write-block read process call to the slave. A command byte,
693 //! length and tx data byte array are required. Ensure that rxData is large
694 //! enough to hold the data received from the slave.
695 //
696 //!
697 //!~~~~~~~~
698 //! SMBus Block write-block read process call protocol
699 //!
700 //! Block write-block read process call:
701 //! 1 7 1 1 8 1 8 1 8 1
702 //! ----------------------------------------------------------------------------------------
703 //! | S | Slave Address | Wr | A | Command Code | A | Byte Count = M | A | Data Byte 1 | A | ...
704 //! ----------------------------------------------------------------------------------------
705 //! 8 1 8 1
706 //! ------------------- -------------------
707 //! | Data Byte 2 | A | ... | Data Byte M | A | ...
708 //! ------------------- -------------------
709 //! 1 7 1 1 8 1 8 1
710 //! ----------------------------------------------------------------------
711 //! | Sr | Slave Address | Rd | A | Byte Count = N | A | Data Byte 1 | A | ...
712 //! ----------------------------------------------------------------------
713 //! 8 1 8 1 1
714 //! ------------------- -----------------------
715 //! | Data Byte 2 | A | ... | Data Byte N | A | P |
716 //! ------------------- -----------------------
717 //! Block write-block read process call with PEC:
718 //! 1 7 1 1 8 1 8 1 8 1
719 //! ----------------------------------------------------------------------------------------
720 //! | S | Slave Address | Wr | A | Command Code | A | Byte Count = M | A | Data Byte 1 | A | ...
721 //! ----------------------------------------------------------------------------------------
722 //! 8 1 8 1
723 //! ------------------- -------------------
724 //! | Data Byte 2 | A | ... | Data Byte M | A | ...
725 //! ------------------- -------------------
726 //! 1 7 1 1 8 1 8 1
727 //! ----------------------------------------------------------------------
728 //! | Sr | Slave Address | Rd | A | Byte Count = N | A | Data Byte 1 | A | ...
729 //! ----------------------------------------------------------------------
730 //! 8 1 8 1 8 1 1
731 //! ------------------- ---------------------------------
732 //! | Data Byte 2 | A | ... | Data Byte N | A | PEC | A | P |
733 //! ------------------- ---------------------------------
734 //!
735 //! where:
736 //! S = Start bit
737 //! Sr = Reapeated Start bit
738 //! Wr = Write bit (0)
739 //! Rd = Read bit (1)
740 //! Slave Adddress = SMBus address for slave
741 //! Command Code = Command byte sent to slave
742 //! Data Byte = data sent to slave
743 //! A = Acknowledge from slave
744 //! PEC = Optional Packet Error Code
745 //! P = Stop bit
746 //!~~~~~~~~
747 //
748 //! \param smbus Pointer to SMBus structure
749 //! \param targetAddr Slave address
750 //! \param command Command byte for slave
751 //! \param txData TX data buffer
752 //! \param txSize Size of the txData buffer
753 //! \param rxData RX data buffer
754 //
755 //! \return \b SMBUS_RET_ERROR, or \b SMBUS_RET_OK
756 //
757 //*****************************************************************************
758 extern int8_t SMBus_masterProcessCallBlock(SMBus *smbus,
759  uint8_t targetAddr,
760  uint8_t command,
761  uint8_t *txData,
762  uint8_t txSize,
763  uint8_t *rxData);
764 
765 //*****************************************************************************
766 //
767 //! \brief Sends byte to the slave
768 //
769 //!
770 //!~~~~~~~~
771 //! SMBus Send Byte command protocol
772 //!
773 //! 1 7 1 1 8 1 1
774 //! ---------------------------------------------------
775 //! | S | Slave Address | Wr | A | Data Byte | A | P |
776 //! ---------------------------------------------------
777 //! Send Byte with PEC:
778 //! 1 7 1 1 8 1 8 1 1
779 //! ------------------------------------------------------------
780 //! | S | Slave Address | Wr | A | Data Byte | A | PEC | A | P |
781 //! ------------------------------------------------------------
782 //!
783 //! where:
784 //! S = Start bit
785 //! Wr = Write bit (0)
786 //! Slave Adddress = SMBus address for slave
787 //! Data Byte = data sent to slave
788 //! A = Acknowledge from slave
789 //! PEC = Optional Packet Error Code
790 //! P = Stop bit
791 //!~~~~~~~~
792 //
793 //! \param smbus Pointer to SMBus structure
794 //! \param targetAddr Slave address
795 //! \param txData TX data buffer
796 //
797 //! \return \b SMBUS_RET_ERROR, or \b SMBUS_RET_OK
798 //
799 //*****************************************************************************
800 extern int8_t SMBus_masterSendByte(SMBus *smbus,
801  uint8_t targetAddr,
802  uint8_t txData);
803 
804 //*****************************************************************************
805 //
806 //! \brief Receive a byte from the slave
807 //
808 //!~~~~~~~~
809 //! SMBus Receive Byte command protocol
810 //!
811 //! 1 7 1 1 8 1 1
812 //! --------------------------------------------------
813 //! | S | Slave Address | Rd | A | Data Byte | A | P |
814 //! --------------------------------------------------
815 //! With PEC:
816 //! 1 7 1 1 8 1 8 1 1
817 //! ------------------------------------------------------------
818 //! | S | Slave Address | Rd | A | Data Byte | A | PEC | A | P |
819 //! ------------------------------------------------------------
820 //!
821 //! where:
822 //! S = Start bit
823 //! Rd = Read bit (1)
824 //! Slave Adddress = SMBus address for slave
825 //! Data Byte = data received from slave
826 //! A = Acknowledge from slave
827 //! PEC = Optional Packet Error Code
828 //! P = Stop bit
829 //!~~~~~~~~
830 //
831 //! \param smbus Pointer to SMBus structure
832 //! \param targetAddr Slave address
833 //! \param rxData RX data buffer
834 //
835 //! \return \b SMBUS_RET_ERROR, or \b SMBUS_RET_OK
836 //
837 //*****************************************************************************
838 extern int8_t SMBus_masterReceiveByte(SMBus *smbus,
839  uint8_t targetAddr,
840  uint8_t *rxData);
841 
842 //*****************************************************************************
843 //
844 //! \brief Receive a block of data from the slave
845 //
846 //! Send block data receive call to the slave. A command byte, length and rx
847 //! data byte array are required. Ensure that rxData is large enough to hold
848 //! the data received from the slave.
849 //
850 //!
851 //!~~~~~~~~
852 //! SMBus Block Read command protocol
853 //!
854 //! Block Read:
855 //! 1 7 1 1 8 1 1 8 1 1
856 //! -------------------------------------------------------------------------------
857 //! | S | Slave Address | Wr | A | Command Code | A | Sr | Slave Address | Rd | A | ...
858 //! -------------------------------------------------------------------------------
859 //! 8 1 8 1 8 1 8 1 1
860 //! ----------------------------------------------------------------------------------------
861 //! | Byte Count = N | A | Data Byte 1 | A | Data Byte 2 | A | ... | Data Byte N | A | P |
862 //! ----------------------------------------------------------------------------------------
863 //! Block Read with PEC:
864 //! 1 7 1 1 8 1 1 8 1 1
865 //! -------------------------------------------------------------------------------
866 //! | S | Slave Address | Wr | A | Command Code | A | Sr | Slave Address | Rd | A | ...
867 //! -------------------------------------------------------------------------------
868 //! 8 1 8 1 8 1 8 1
869 //! ------------------------------------------------------------------------------------
870 //! | Byte Count = N | A | Data Byte 1 | A | Data Byte 2 | A | ... | Data Byte N | A |...
871 //! ------------------------------------------------------------------------------------
872 //! 8 1 1
873 //! ---------------
874 //! | PEC | A | P |
875 //! ---------------
876 //!
877 //! where:
878 //! S = Start bit
879 //! Sr = Reapeated Start bit
880 //! Wr = Write bit (0)
881 //! Rd = Read bit (1)
882 //! Slave Adddress = SMBus address for slave
883 //! Command Code = Command byte sent to slave
884 //! Data Byte = data sent to slave
885 //! A = Acknowledge from slave
886 //! PEC = Optional Packet Error Code
887 //! P = Stop bit
888 //!~~~~~~~~
889 //
890 //! \param smbus Pointer to SMBus structure
891 //! \param targetAddr Slave address
892 //! \param command Command byte for slave
893 //! \param rxData RX data buffer
894 //
895 //! \return \b SMBUS_RET_ERROR, or \b SMBUS_RET_OK
896 //
897 //*****************************************************************************
898 extern int8_t SMBus_masterReadBlock(SMBus *smbus,
899  uint8_t targetAddr,
900  uint8_t command,
901  uint8_t *rxData);
902 
903 //*****************************************************************************
904 //
905 //! \brief Transmit a block of data to the slave
906 //
907 //! Send block of data to the slave. A command byte, length and tx
908 //! data byte array are required.
909 //
910 //!
911 //!~~~~~~~~
912 //! SMBus Block Write command protocol
913 //!
914 //! Block Write:
915 //! 1 7 1 1 8 1 8 1 8 1
916 //! ----------------------------------------------------------------------------------------
917 //! | S | Slave Address | Wr | A | Command Code | A | Byte Count = N | A | Data Byte 1 | A | ...
918 //! ----------------------------------------------------------------------------------------
919 //! 8 1 8 1 1
920 //! -------------------- -----------------------
921 //! | Data Byte 2 | A | ... | Data Byte N | A | P |
922 //! -------------------- -----------------------
923 //! Block Write with PEC:
924 //! 1 7 1 1 8 1 8 1 8 1
925 //! ----------------------------------------------------------------------------------------
926 //! | S | Slave Address | Wr | A | Command Code | A | Byte Count = N | A | Data Byte 1 | A | ...
927 //! ----------------------------------------------------------------------------------------
928 //! 8 1 8 1 8 1 1
929 //! -------------------- ---------------------------------
930 //! | Data Byte 2 | A | ... | Data Byte N | A | PEC | A | P |
931 //! -------------------- ---------------------------------
932 //!
933 //! where:
934 //! S = Start bit
935 //! Wr = Write bit (0)
936 //! Slave Adddress = SMBus address for slave
937 //! Command Code = Command byte sent to slave
938 //! Data Byte = data sent to slave
939 //! A = Acknowledge from slave
940 //! PEC = Optional Packet Error Code
941 //! P = Stop bit
942 //!~~~~~~~~
943 //
944 //! \param smbus Pointer to SMBus structure
945 //! \param targetAddr Slave address
946 //! \param command Command byte for slave
947 //! \param txData TX data buffer
948 //! \param txSize Size of the txData buffer
949 //
950 //! \return \b SMBUS_RET_ERROR, or \b SMBUS_RET_OK
951 //
952 //*****************************************************************************
953 extern int8_t SMBus_masterWriteBlock(SMBus *smbus,
954  uint8_t targetAddr,
955  uint8_t command,
956  uint8_t *txData,
957  uint8_t txSize);
958 
959 //*****************************************************************************
960 //
961 //! \brief Send a command requesting a byte or word of data from the slave
962 //
963 //
964 //!~~~~~~~~
965 //! SMBus Read ByteWord command protocol
966 //!
967 //! Read Byte:
968 //! 1 7 1 1 8 1 8 1 1 8 1 1
969 //! ----------------------------------------------------------------------------------------------
970 //! | S | Slave Address | Wr | A | Command Code | S | Slave Address | Rd | A | Data Byte | A | P |
971 //! ----------------------------------------------------------------------------------------------
972 //! Read Byte with PEC:
973 //! 1 7 1 1 8 1 8 1 1 8 1 1
974 //! ----------------------------------------------------------------------------------------------
975 //! | S | Slave Address | Wr | A | Command Code | S | Slave Address | Rd | A | Data Byte | A | P | ...
976 //! ----------------------------------------------------------------------------------------------
977 //! 8 1 1
978 //! ---------------
979 //! | PEC | A | P |
980 //! ---------------
981 //!
982 //! Read Word:
983 //! 1 7 1 1 8 1 8 1 1 8 1 1
984 //! --------------------------------------------------------------------------------------------------
985 //! | S | Slave Address | Wr | A | Command Code | S | Slave Address | Rd | A | Data Byte Low | A | P | ...
986 //! --------------------------------------------------------------------------------------------------
987 //! 8 1 1
988 //! --------------------------
989 //! | Data Byte High | A | P |
990 //! --------------------------
991 //! Read Word with PEC:
992 //! 1 7 1 1 8 1 8 1 1 8 1 1
993 //! --------------------------------------------------------------------------------------------------
994 //! | S | Slave Address | Wr | A | Command Code | S | Slave Address | Rd | A | Data Byte Low | A | P | ...
995 //! --------------------------------------------------------------------------------------------------
996 //! 8 1 1 8 1 1
997 //! ----------------------------------------
998 //! | Data Byte High | A | P | PEC | A | P |
999 //! ----------------------------------------
1000 //!
1001 //! where:
1002 //! S = Start bit
1003 //! Wr = Read bit (0)
1004 //! Rd = Read bit (1)
1005 //! Slave Adddress = SMBus address for slave
1006 //! Command Code = Command byte sent to slave
1007 //! Data Byte = data sent to slave
1008 //! A = Acknowledge from slave
1009 //! PEC = Optional Packet Error Code
1010 //! P = Stop bit
1011 //!~~~~~~~~
1012 //
1013 //! \param smbus Pointer to SMBus structure
1014 //! \param targetAddr Slave address
1015 //! \param command Command byte for slave
1016 //! \param rxData RX data buffer
1017 //! \param rxSize Must be 1 or 2 bytes
1018 //
1019 //! \return \b SMBUS_RET_ERROR, or \b SMBUS_RET_OK
1020 //
1021 //*****************************************************************************
1022 extern int8_t SMBus_masterReadByteWord(SMBus *smbus,
1023  uint8_t targetAddr,
1024  uint8_t command,
1025  uint8_t *rxData,
1026  uint8_t rxSize);
1027 
1028 //*****************************************************************************
1029 //
1030 //! \brief Send a command transmitting a byte or word of data from the slave
1031 //!
1032 //!~~~~~~~~
1033 //! SMBus Write ByteWord command protocol
1034 //!
1035 //! Write Byte:
1036 //! 1 7 1 1 8 1 8 1 1
1037 //! ---------------------------------------------------------------------
1038 //! | S | Slave Address | Wr | A | Command Code | A | Data Byte | A | P |
1039 //! ---------------------------------------------------------------------
1040 //! Write Byte with PEC:
1041 //! 1 7 1 1 8 1 8 1 8 1 1
1042 //! -------------------------------------------------------------------------------
1043 //! | S | Slave Address | Wr | A | Command Code | A | Data Byte | A | PEC | A | P |
1044 //! -------------------------------------------------------------------------------
1045 //!
1046 //! Write Word:
1047 //! 1 7 1 1 8 1 8 1 8 1 1
1048 //! ----------------------------------------------------------------------------------------------
1049 //! | S | Slave Address | Wr | A | Command Code | A | Data Byte Low | A | Data Byte High | A | P |
1050 //! ----------------------------------------------------------------------------------------------
1051 //! Write Word with PEC:
1052 //! 1 7 1 1 8 1 8 1 8 1 8 1 1
1053 //! --------------------------------------------------------------------------------------------------------
1054 //! | S | Slave Address | Wr | A | Command Code | A | Data Byte Low | A | Data Byte High | A | PEC | A | P |
1055 //! --------------------------------------------------------------------------------------------------------
1056 //!
1057 //! where:
1058 //! S = Start bit
1059 //! Wr = Write bit (0)
1060 //! Slave Adddress = SMBus address for slave
1061 //! Command Code = Command byte sent to slave
1062 //! Data Byte = data sent to slave
1063 //! A = Acknowledge from slave
1064 //! PEC = Optional Packet Error Code
1065 //! P = Stop bit
1066 //!~~~~~~~~
1067 //
1068 //! \param smbus Pointer to SMBus structure
1069 //! \param targetAddr Slave address
1070 //! \param command Command byte for slave
1071 //! \param txData TX data buffer
1072 //! \param txSize Must be 1 or 2 bytes
1073 //
1074 //! \return \b SMBUS_RET_ERROR, or \b SMBUS_RET_OK
1075 //
1076 //*****************************************************************************
1077 extern int8_t SMBus_masterWriteByteWord(SMBus *smbus,
1078  uint8_t targetAddr,
1079  uint8_t command,
1080  uint8_t *txData,
1081  uint8_t txSize);
1082 
1083 //*****************************************************************************
1084 //
1085 //! \brief Send a SMBus "quick command"
1086 //
1087 //! A "quick command" is only a trigger. There is no data sent or received.
1088 //!
1089 //!~~~~~~~~
1090 //! SMBus Quick Commmand Protocol:
1091 //! 1 7 1 1 1
1092 //! -------------------------------------
1093 //! | S | Slave Address | Rd/Wr | A | P |
1094 //! -------------------------------------
1095 //! where:
1096 //! S = Start bit
1097 //! Rd/Wr = Read or Write bit
1098 //! Slave Adddress = SMBus address for slave
1099 //! A = Acknowledge from slave
1100 //! P = Stop bit
1101 //!~~~~~~~~
1102 //
1103 //! \param smbus Pointer to SMBus structure
1104 //! \param targetAddr Slave address
1105 //! \param write true if this is a write command, false if this is a read command
1106 //
1107 //! \return \b SMBUS_RET_ERROR, or \b SMBUS_RET_OK
1108 //
1109 //*****************************************************************************
1110 extern int8_t SMBus_masterQuickCommand(SMBus *smbus,
1111  uint8_t targetAddr,
1112  bool write);
1113 
1114 //*****************************************************************************
1115 //
1116 //! \brief Wait until the previous SMBus command is executed
1117 //
1118 //! \param smbus Pointer to SMBus structure
1119 //! \param timeout Software timeout
1120 //
1121 //! \return \b SMBUS_RET_ERROR, or \b SMBUS_RET_OK
1122 //
1123 //*****************************************************************************
1124 extern int8_t SMBus_masterWaitUntilDone(SMBus *smbus,
1125  int32_t timeout);
1126 
1127 //*****************************************************************************
1128 //
1129 // Mark the end of the C bindings section for C++ compilers.
1130 //
1131 //*****************************************************************************
1132 #ifdef __cplusplus
1133 }
1134 #endif
1135 
1136 //*****************************************************************************
1137 //
1138 // Close the Doxygen group.
1139 //! @}
1140 //
1141 //*****************************************************************************
1142 
1143 #endif //__SMBUS_H__
void SMBus_masterReset(SMBus *smbus)
Force reset to SMBus master interface.
Definition: smbus.c:225
Stop is send immediately with Start.
Definition: smbus.h:114
SMBus_State SMBus_slaveProcessTimeoutInt(SMBus *smbus)
Timer interrupt service routine for slave application.
Definition: smbus.c:94
Stop sent before reading next byte.
Definition: smbus.h:116
uint8_t SMBus_slaveGetCommand(SMBus *smbus)
Return the current command (Rxbuffer[0]) received by the slave.
Definition: smbus.c:150
Network is receiving a packet.
Definition: smbus.h:174
uint8_t SMBus_slaveClearStatusReg(SMBus *smbus, uint8_t val)
Clear the slave's status register.
Definition: smbus.c:155
uint8_t currentCmd
Current Address+R/W.
Definition: smbus.h:192
Nothing special to report.
Definition: smbus.h:227
uint8_t txIndex
Reception Buffer pointer.
Definition: smbus.h:197
SMBus_Nwk nwk
PHY and DataLink object.
Definition: smbus.h:277
PEC Error detected.
Definition: smbus.h:229
SMBus_Ctrl ctrl
Network object.
Definition: smbus.h:278
void SMBus_slaveSetAddress(SMBus *smbus, uint8_t slaveAddr)
Set the slave's own I2C address.
Definition: smbus.c:101
SMBus_Stop SMBus_Phy_stop
I2C Base address.
Definition: smbus.h:162
SMBus_ErrorCode
List of error codes used by the application to indicate an error to the library.
Definition: smbus.h:212
Timeout Error.
Definition: smbus.h:230
uint8_t u8byte
Whole status byte access.
Definition: smbus.h:266
SMBus Slave Error.
Definition: smbus.h:235
SMBus control register.
Definition: smbus.h:124
1st byte (cmd) received
Definition: smbus.h:231
uint8_t * txBuffPtr
Bytes to send.
Definition: smbus.h:199
SMBus Master error.
Definition: smbus.h:240
SMBus_State state
SMBus Status register.
Definition: smbus.h:280
int8_t SMBus_masterProcessCall(SMBus *smbus, uint8_t targetAddr, uint8_t command, uint8_t *txData, uint8_t *rxData)
Sends a process call to a slave.
Definition: smbus.c:238
void SMBus_slaveEnableInt(SMBus *smbus)
Enables the I2C interrupts for a slave.
Definition: smbus.c:71
void SMBus_disablePEC(SMBus *smbus)
Disables PEC support.
Definition: smbus.c:38
uint8_t ownSlaveAddr
SMBus reported state.
Definition: smbus.h:281
SMBus_State SMBus_masterProcessTimeoutInt(SMBus *smbus)
Timer interrupt service routine for a master.
Definition: smbus.c:231
Quick Command detected.
Definition: smbus.h:233
int8_t SMBus_masterReadByteWord(SMBus *smbus, uint8_t targetAddr, uint8_t command, uint8_t *rxData, uint8_t rxSize)
Send a command requesting a byte or word of data from the slave.
Definition: smbus.c:380
void SMBus_slaveSetTxBuffer(SMBus *smbus, uint8_t *data, uint8_t size)
Initialize the transmission buffer for slave.
Definition: smbus.c:123
int8_t SMBus_masterQuickCommand(SMBus *smbus, uint8_t targetAddr, bool write)
Send a SMBus "quick command".
Definition: smbus.c:436
int8_t SMBus_masterProcessCallBlock(SMBus *smbus, uint8_t targetAddr, uint8_t command, uint8_t *txData, uint8_t txSize, uint8_t *rxData)
Sends a block write-block read process call.
Definition: smbus.c:262
Network is transmitting after receive byte.
Definition: smbus.h:175
void SMBus_processDone(SMBus *smbus)
Clears the current state of SMBus.
Definition: smbus.c:16
SMBus Buffers haven't been initialized.
Definition: smbus.h:236
Unexpected NACKed.
Definition: smbus.h:239
int8_t SMBus_masterReadBlock(SMBus *smbus, uint8_t targetAddr, uint8_t command, uint8_t *rxData)
Receive a block of data from the slave.
Definition: smbus.c:331
int8_t SMBus_masterReceiveByte(SMBus *smbus, uint8_t targetAddr, uint8_t *rxData)
Receive a byte from the slave.
Definition: smbus.c:311
uint8_t txSize
Receive Byte response.
Definition: smbus.h:201
void SMBus_masterEnableInt(SMBus *smbus)
Enables the I2C interrupts for a master.
Definition: smbus.c:215
uint8_t rxIndex
Current Command.
Definition: smbus.h:193
int8_t SMBus_masterWriteByteWord(SMBus *smbus, uint8_t targetAddr, uint8_t command, uint8_t *txData, uint8_t txSize)
Send a command transmitting a byte or word of data from the slave.
Definition: smbus.c:408
int8_t SMBus_masterWriteBlock(SMBus *smbus, uint8_t targetAddr, uint8_t command, uint8_t *txData, uint8_t txSize)
Transmit a block of data to the slave.
Definition: smbus.c:353
uint8_t u8byte
Whole Control byte access.
Definition: smbus.h:151
void SMBus_enablePEC(SMBus *smbus)
Enables PEC support.
Definition: smbus.c:33
SMBus_State SMBus_slaveProcessInt(SMBus *smbus)
I2C Interrupt Service routine for a slave.
Definition: smbus.c:76
Slave received a byte (2-n)
Definition: smbus.h:232
uint8_t * recByteTxPtr
Transmission pointer.
Definition: smbus.h:200
SMBus_State SMBus_getState(SMBus *smbus)
Returns the state of the SMBus module.
Definition: smbus.c:27
SMBus_State SMBus_masterProcessInt(SMBus *smbus)
I2C Interrupt Service routine for a master.
Definition: smbus.c:220
Incorrect packet size.
Definition: smbus.h:228
Network is sending Quick Command.
Definition: smbus.h:176
SMBus_NwkState
SMBus network layer states.
Definition: smbus.h:170
void SMBus_slaveSetRxBuffer(SMBus *smbus, uint8_t *data, uint8_t size)
Initialize the reception buffer for slave.
Definition: smbus.c:114
uint8_t * rxBuffPtr
Max size of buffer.
Definition: smbus.h:196
int8_t SMBus_masterWaitUntilDone(SMBus *smbus, int32_t timeout)
Wait until the previous SMBus command is executed.
Definition: smbus.c:463
SMBus_Status status
SMBus Control register.
Definition: smbus.h:279
SMBus_State
SMBus state sent to application layer.
Definition: smbus.h:224
Network is transmitting a block.
Definition: smbus.h:178
Physical and Data Link Layer object.
Definition: smbus.h:159
uint8_t currentAddr
Network state machine.
Definition: smbus.h:191
No Interrupt flags detected.
Definition: smbus.h:237
void SMBus_slaveReportError(SMBus *smbus, SMBus_ErrorCode errorCode)
Reports an error to SMBus driver from the slave.
Definition: smbus.c:132
uint8_t txLen
Byte counter.
Definition: smbus.h:198
Complete packet received by slave.
Definition: smbus.h:234
Incorrect packet was received.
Definition: smbus.h:216
uint8_t rxLen
RX Byte counter.
Definition: smbus.h:194
Main SMBus object.
Definition: smbus.h:274
uint8_t rxSize
Bytes to receive.
Definition: smbus.h:195
uint8_t pec
Max size of buffer.
Definition: smbus.h:203
Network is idle and waiting for new packet.
Definition: smbus.h:173
void SMBus_masterInit(SMBus *smbus, uint16_t i2cAddr, uint32_t busClk)
Initialize the SMBus Interface for a master.
Definition: smbus.c:189
SMBus_Stop
List of stop codes used within the NWK and PHY layers.
Definition: smbus.h:110
int8_t SMBus_masterSendByte(SMBus *smbus, uint8_t targetAddr, uint8_t txData)
Sends byte to the slave.
Definition: smbus.c:292
Network is transmitting a response after restart.
Definition: smbus.h:177
uint8_t SMBus_slaveWriteCtrlReg(SMBus *smbus, uint8_t val)
Write a value to the slave's control register.
Definition: smbus.c:162
SMBus Status Register.
Definition: smbus.h:248
Arbitration Lost.
Definition: smbus.h:238
Stop is send after Start.
Definition: smbus.h:115
uint8_t SMBus_getRxPayloadAvailable(SMBus *smbus)
Returns the number of received bytes from last transaction.
Definition: smbus.c:22
Network is receiving a block.
Definition: smbus.h:179
Definition of SMBus Network structure.
Definition: smbus.h:188
void SMBus_slaveInit(SMBus *smbus, uint16_t i2cAddr)
Initialize the SMBus interface as a slave.
Definition: smbus.c:45
No error detected.
Definition: smbus.h:215
Network is finishing transfer.
Definition: smbus.h:180
No Stop send.
Definition: smbus.h:113

Copyright 2015, Texas Instruments Incorporated