5 const int32_t MCP355X_OVH =  2097152L;
     6 const int32_t MCP355X_OVL = -2097153L;
     7 const int32_t MCP355X_ERR = 0X80000000;
     8 const uint8_t MCP355X_TO_MS = 100;
    10 template<u
int8_t CsPin, u
int8_t SckPin, u
int8_t SdoPin>
    17     void begin(
bool singleMode = 
true)
    19         m_singleMode = singleMode;
    20         fastPinMode(SdoPin, 0);
    21         fastPinMode(SckPin, 1);
    22         fastDigitalWrite(SckPin, 1);
    23         fastPinMode(CsPin, 1);
    24         fastDigitalWrite(CsPin, 1);
    29             fastDigitalWrite(CsPin, 0);
    43             fastDigitalWrite(CsPin, 0);
    47             fastDigitalWrite(CsPin, 1);
    51                 fastDigitalWrite(CsPin, 0);
    54                 if (!fastDigitalRead(SdoPin)) {
    57                 fastDigitalWrite(CsPin, 1);
    58                 if (t++ > MCP355X_TO_MS) {
    64                 if (!fastDigitalRead(SdoPin)) {
    68                 if (t++ > MCP355X_TO_MS) {
    73         uint8_t v2 = readByte();
    74         uint8_t v1 = readByte();
    75         uint8_t v0 = readByte();
    82             fastDigitalWrite(CsPin, 1);
    84         if ((v2 & 0XE0) == 0X20) {
    88         } 
else if (v2 & 0X40) {
    93         } 
else if (v2 & 0X80) {
    95             if ((v2 & 0X20) == 0) {
   100         uint16_t v_high = (v3 << 8) | v2;
   101         uint16_t v_low = (v1 << 8) | v0;
   102         return ((uint32_t)v_high << 16) | v_low;
   110     void delayCycles(uint8_t n)
   113             asm volatile(
"nop\n\t");
   116             asm volatile(
"nop\n\t" "nop\n\t");
   119             asm volatile(
"nop\n\t" "nop\n\t" "nop\n\t" "nop\n\t");
   125     void readBit(uint8_t &v, uint8_t b, uint8_t delayRead = 0)
   127         fastDigitalWrite(SckPin, 0);
   128         delayCycles(2 + delayRead);
   129         fastDigitalWrite(SckPin, 1);
   130         if (fastDigitalRead(SdoPin)) {
   133         delayCycles(delayRead);
 Fast Digital I/O functions. 
void begin(bool singleMode=true)
Definition: MCP355X.h:17
__attribute__((always_inline)) int32_t read()
Definition: MCP355X.h:36