From c46b2a762d03874eb712250c7849759f9b13a093 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Sun, 16 Jul 2017 13:21:14 -0500 Subject: [PATCH] Added support for Travis CI --- .travis.yml | 28 ++++++++++++++++++++++++++++ README.md | 2 +- SPIFBlockDevice.h | 42 +++++++++++++++++++++++++----------------- 3 files changed, 54 insertions(+), 18 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..bc3c5de502 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,28 @@ +script: + # Check that examples compile + - sed -n '/``` cpp/,${/```$/q;/```/d;p}' README.md > main.cpp && + PYTHONPATH=mbed-os python mbed-os/tools/make.py -t GCC_ARM -m K82F + --source=. --build=BUILD/K82F/GCC_ARM -j0 && + rm main.cpp + - sed -n '/@code/,${/@endcode/q;/@/d;s/^ \*//;p}' SPIFBlockDevice.h > main.cpp && + PYTHONPATH=mbed-os python mbed-os/tools/make.py -t GCC_ARM -m K82F + --source=. --build=BUILD/K82F/GCC_ARM -j0 && + rm main.cpp + + # Check that tests compile + - rm -r BUILD && PYTHONPATH=mbed-os python mbed-os/tools/test.py + -t GCC_ARM -m K82F --source=. --build=BUILD/TESTS/K82F/GCC_ARM -j0 + -n tests* + +python: + - "2.7" + +install: + # Get arm-none-eabi-gcc + - sudo add-apt-repository -y ppa:terry.guo/gcc-arm-embedded + - sudo apt-get update -qq + - sudo apt-get install -qq gcc-arm-none-eabi --force-yes + # Get dependencies + - git clone https://github.com/armmbed/mbed-os.git + # Install python dependencies + - sudo pip install -r mbed-os/requirements.txt diff --git a/README.md b/README.md index 7f7113fa3a..1f9c3ae41b 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ int main() { printf("spif erase size: %llu\n", spif.get_erase_size()); // Write "Hello World!" to the first block - uint8_t *buffer = malloc(spif.get_erase_size()); + char *buffer = (char*)malloc(spif.get_erase_size()); sprintf(buffer, "Hello World!\n"); spif.erase(0, spif.get_erase_size()); spif.program(buffer, 0, spif.get_erase_size()); diff --git a/SPIFBlockDevice.h b/SPIFBlockDevice.h index a443da02a5..c4ee447e2f 100644 --- a/SPIFBlockDevice.h +++ b/SPIFBlockDevice.h @@ -24,29 +24,37 @@ * such as the MX25R or SST26F016B * * @code + * // Here's an example using the MX25R SPI flash device on the K82F * #include "mbed.h" * #include "SPIFBlockDevice.h" - * - * // Create mx25r on SPI bus with PTE5 as chip select - * SPIFBlockDevice mx25r(PTE2, PTE4, PTE1, PTE5); - * + * + * // Create flash device on SPI bus with PTE5 as chip select + * SPIFBlockDevice spif(PTE2, PTE4, PTE1, PTE5); + * * int main() { - * printf("mx25r test\n"); - * mx52r.init(); - * printf("mx25r size: %llu\n", mx25r.size()); - * printf("mx25r read size: %llu\n", mx25r.get_read_size()); - * printf("mx25r program size: %llu\n", mx25r.get_program_size()); - * printf("mx25r erase size: %llu\n", mx25r.get_erase_size()); - * - * uint8_t *buffer = malloc(mx25r.get_erase_size()); + * printf("spif test\n"); + * + * // Initialize the SPI flash device and print the memory layout + * spif.init(); + * printf("spif size: %llu\n", spif.size()); + * printf("spif read size: %llu\n", spif.get_read_size()); + * printf("spif program size: %llu\n", spif.get_program_size()); + * printf("spif erase size: %llu\n", spif.get_erase_size()); + * + * // Write "Hello World!" to the first block + * char *buffer = (char*)malloc(spif.get_erase_size()); * sprintf(buffer, "Hello World!\n"); - * mx25r.erase(0, mx25r.get_erase_size()); - * mx25r.program(buffer, 0, mx25r.get_erase_size()); - * mx25r.read(buffer, 0, mx25r.get_erase_size()); + * spif.erase(0, spif.get_erase_size()); + * spif.program(buffer, 0, spif.get_erase_size()); + * + * // Read back what was stored + * spif.read(buffer, 0, spif.get_erase_size()); * printf("%s", buffer); - * - * mx25r.deinit(); + * + * // Deinitialize the device + * spif.deinit(); * } + * @endcode */ class SPIFBlockDevice : public BlockDevice { public: