3 Copyright (C) Dean Camera, 2009.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
31 #if defined(ENABLE_PDI_PROTOCOL) || defined(__DOXYGEN__)
35 * Target-related functions for the PDI Protocol decoder.
38 #define INCLUDE_FROM_PDITARGET_C
39 #include "PDITarget.h"
41 /** Writes a given byte to the attached XMEGA device, using a RS232 frame via software through the
44 * \param[in] Byte Byte to send to the attached device
46 void PDITarget_SendByte(uint8_t Byte
)
48 uint8_t LogicOneBits
= 0;
51 PDIDATA_LINE_PORT
&= ~PDIDATA_LINE_MASK
;
56 for (uint8_t i
= 0; i
< 8; i
++)
60 PDIDATA_LINE_PORT
&= ~PDIDATA_LINE_MASK
;
65 PDIDATA_LINE_PORT
|= PDIDATA_LINE_MASK
;
74 if (LogicOneBits
& 0x01)
75 PDIDATA_LINE_PORT
&= ~PDIDATA_LINE_MASK
;
77 PDIDATA_LINE_PORT
|= PDIDATA_LINE_MASK
;
82 PDIDATA_LINE_PORT
|= PDIDATA_LINE_MASK
;
88 /** Reads a given byte from the attached XMEGA device, encoded in a RS232 frame through the PDI interface.
90 * \return Received byte from the attached device
92 uint8_t PDITarget_ReceiveByte(void)
94 uint8_t ReceivedByte
= 0;
96 PDIDATA_LINE_DDR
&= ~PDIDATA_LINE_MASK
;
99 while (PDIDATA_LINE_PIN
& PDIDATA_LINE_MASK
);
103 for (uint8_t i
= 0; i
< 8; i
++)
105 if (PDIDATA_LINE_PIN
& PDIDATA_LINE_MASK
)
106 ReceivedByte
|= 0x01;
113 // Even Parity Bit (discarded)
120 PDIDATA_LINE_DDR
|= PDIDATA_LINE_MASK
;