40 void sd_error_checker (
const ErrorCode err) {
53 TEST(DefaultConstructor_RELIES_ON_DNA_BOARD) {
57 ASSERT_EQ_MSG(
Port::P2, testable->m_spi->m_mosi.get_mask());
58 ASSERT_EQ_MSG(
Port::P1, testable->m_spi->m_sclk.get_mask());
59 ASSERT_EQ_MSG(
Port::P0, testable->m_spi->m_miso.get_mask());
60 ASSERT_EQ_MSG(
Port::P3, testable->m_cs.get_mask());
68 ErrorCode err = testable->
start();
69 sd_error_checker(err);
78 uint8_t buffer[SD::SECTOR_SIZE];
80 ErrorCode err = testable->
start();
81 sd_error_checker(err);
82 ASSERT_EQ_MSG(0, err);
85 memset(buffer, 0,
sizeof(buffer));
89 sd_error_checker(err);
94 for (
unsigned int j = 0; j <
sizeof(buffer); ++j)
103 TEST(WriteDataBlock) {
106 uint8_t originalBlock[SD::SECTOR_SIZE];
107 uint8_t moddedBlock[SD::SECTOR_SIZE];
108 const uint8_t *myData = 0;
109 const uint8_t sdBlockAddr = 0;
111 ErrorCode err = testable->
start();
112 sd_error_checker(err);
113 ASSERT_EQ_MSG(0, err);
117 sd_error_checker(err);
119 MESSAGE(
"WriteBlock: Original block read in");
123 sd_error_checker(err);
125 MESSAGE(
"WriteBlock: Random block written");
129 sd_error_checker(err);
131 MESSAGE(
"WriteBlock: Modded block read");
132 ASSERT_EQ_MSG(0, memcmp(myData, moddedBlock, SD::SECTOR_SIZE));
133 MESSAGE(
"WriteBlock: Modded block equals random block");
137 sd_error_checker(err);
139 MESSAGE(
"WriteBlock: Original block written back");
143 sd_error_checker(err);
145 MESSAGE(
"WriteBlock: Modded block read again");
146 ASSERT_EQ_MSG(0, memcmp(originalBlock, moddedBlock, SD::SECTOR_SIZE));
147 MESSAGE(
"WriteBlock: Modded block matches original");
155 RUN_TEST(DefaultConstructor_RELIES_ON_DNA_BOARD);
157 RUN_TEST(ReadDataBlock);
158 RUN_TEST(WriteDataBlock);
PropWare::ErrorCode read_data_block(const uint32_t address, uint8_t buf[]) const
Read a block of data from the device into RAM.
Generic definitions and functions for the Parallax Propeller.
const PropWare::Printer pwOut
Most common use of printing in PropWare applications (not thread safe; see PropWare::pwSyncOut for mu...
void print_error_str(const Printer &printer, const ErrorCode err)
Create a human-readable error string.
PropWare::ErrorCode start() const
Initialize SD card communication over SPI for 3.3V configuration.
PropWare::ErrorCode write_data_block(uint32_t address, const uint8_t dat[]) const
Write data to a storage device.
A simple SD driver communicating over the SPI protocol.
static SPI * get_instance()
Best way to use SPI is through here, where you can get a shared instance of the SPI module (not threa...