data must be long aligned
| 137 | |
| 138 | // data must be long aligned |
| 139 | uint8_t ICACHE_RAM_ATTR modSpiLoadBufferAsIs(uint8_t *data, uint8_t bytes) |
| 140 | { |
| 141 | uint32_t *from = (uint32_t *)data, *to = (uint32_t *)SPI_FLASH_C0(HSPI); |
| 142 | uint16_t bits = (bytes << 3) - 1; |
| 143 | |
| 144 | WRITE_PERI_REG(SPI_FLASH_USER1(HSPI), |
| 145 | ( (bits & SPI_USR_OUT_BITLEN) << SPI_USR_OUT_BITLEN_S ) | |
| 146 | ( (bits & SPI_USR_DIN_BITLEN) << SPI_USR_DIN_BITLEN_S ) ); |
| 147 | |
| 148 | if (64 == bytes) { |
| 149 | *to++ = *from++; |
| 150 | *to++ = *from++; |
| 151 | *to++ = *from++; |
| 152 | *to++ = *from++; |
| 153 | *to++ = *from++; |
| 154 | *to++ = *from++; |
| 155 | *to++ = *from++; |
| 156 | *to++ = *from++; |
| 157 | *to++ = *from++; |
| 158 | *to++ = *from++; |
| 159 | *to++ = *from++; |
| 160 | *to++ = *from++; |
| 161 | *to++ = *from++; |
| 162 | *to++ = *from++; |
| 163 | *to++ = *from++; |
| 164 | *to = *from; |
| 165 | } |
| 166 | else { |
| 167 | uint8_t longs = (bytes + 3) >> 2; |
| 168 | while (longs--) |
| 169 | *to++ = *from++; |
| 170 | } |
| 171 | |
| 172 | return bytes; |
| 173 | } |
| 174 | |
| 175 | uint8_t ICACHE_RAM_ATTR modSpiLoadBufferSwap16(uint8_t *data, uint8_t bytes) |
| 176 | { |