@@ -231,6 +231,13 @@ bool Sd2Card::eraseSingleBlockEnable() {
231
231
* The reason for failure can be determined by calling errorCode() and errorData().
232
232
*/
233
233
bool Sd2Card::init (const uint8_t sckRateID, const pin_t chipSelectPin) {
234
+ #if IS_TEENSY_35_36 || IS_TEENSY_40_41
235
+ chipSelectPin_ = BUILTIN_SDCARD;
236
+ const uint8_t ret = SDHC_CardInit ();
237
+ type_ = SDHC_CardGetType ();
238
+ return (ret == 0 );
239
+ #endif
240
+
234
241
errorCode_ = type_ = 0 ;
235
242
chipSelectPin_ = chipSelectPin;
236
243
// 16-bit init start time allows over a minute
@@ -332,6 +339,10 @@ bool Sd2Card::init(const uint8_t sckRateID, const pin_t chipSelectPin) {
332
339
* \return true for success, false for failure.
333
340
*/
334
341
bool Sd2Card::readBlock (uint32_t blockNumber, uint8_t * dst) {
342
+ #if IS_TEENSY_35_36 || IS_TEENSY_40_41
343
+ return 0 == SDHC_CardReadBlock (dst, blockNumber);
344
+ #endif
345
+
335
346
if (type () != SD_CARD_TYPE_SDHC) blockNumber <<= 9 ; // Use address if not SDHC card
336
347
337
348
#if ENABLED(SD_CHECK_AND_RETRY)
@@ -547,6 +558,10 @@ bool Sd2Card::waitNotBusy(const millis_t timeout_ms) {
547
558
bool Sd2Card::writeBlock (uint32_t blockNumber, const uint8_t * src) {
548
559
if (ENABLED (SDCARD_READONLY)) return false ;
549
560
561
+ #if IS_TEENSY_35_36 || IS_TEENSY_40_41
562
+ return 0 == SDHC_CardWriteBlock (src, blockNumber);
563
+ #endif
564
+
550
565
bool success = false ;
551
566
if (type () != SD_CARD_TYPE_SDHC) blockNumber <<= 9 ; // Use address if not SDHC card
552
567
if (!cardCommand (CMD24, blockNumber)) {
0 commit comments