MCPcopy Create free account
hub / github.com/SmingHub/Sming / readMemoryBlock

Method readMemoryBlock

Sming/Libraries/ArduCAM/ArduCAMStream.cpp:80–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78
79
80uint16_t ArduCAMStream::readMemoryBlock(char* data, int bufSize) {
81 if(!dataReady()) {
82 return 0;
83 }
84
85 if (!transfer) {
86 transfer = true;
87
88 myCAM->CS_LOW();
89 myCAM->set_fifo_burst();
90 // clear dummy byte -> send out LO and ignore MISO
91 SPI.transfer(0x0);
92
93 // send a BMP header for BMP files
94 if (myCAM->get_format() == BMP) {
95 hdump.print((unsigned char *)bmp_header, BMPIMAGEOFFSET);
96 memcpy(data, (unsigned char *)bmp_header, BMPIMAGEOFFSET);
97 return BMPIMAGEOFFSET;
98 }
99
100 }
101
102 int bytesread = min(len, size_t(bufSize));
103
104 ACAM_DEBUG("ArduCAMStream::readMemoryBlock [%d] (%d bytes) remaining (%d bytes)\n", bcount++, bytesread, len);
105
106 // block read does overload the cam
107// HwSPI.recv((uint8_t *)data, bytesread);
108// SPI.transfer((unsigned char*)data, bytesread);
109
110 // so we have to read single bytes
111 for (int i=0; i< bytesread; i++) {
112 data[i] = SPI.read8();
113 }
114 len = len - bytesread;
115
116 if (len == 0) {
117 ACAM_DEBUG("ArduCAMStream::readMemoryBlock -> eof");
118 transfer = false;
119 SPI.endTransaction();
120 myCAM->CS_HIGH();
121 }
122
123 return bytesread;
124
125}
126
127bool ArduCAMStream::seek(int dist) {
128// ACAM_DEBUG("ArduCAMStream::seek (%d)\n", dist);

Callers

nothing calls this directly

Calls 9

minFunction · 0.85
CS_LOWMethod · 0.80
set_fifo_burstMethod · 0.80
get_formatMethod · 0.80
CS_HIGHMethod · 0.80
transferMethod · 0.45
printMethod · 0.45
read8Method · 0.45
endTransactionMethod · 0.45

Tested by

no test coverage detected