Skip to content

Commit 2be4faf

Browse files
committed
Added support for Travis CI
1 parent 69da721 commit 2be4faf

File tree

3 files changed

+54
-18
lines changed

3 files changed

+54
-18
lines changed

.travis.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
script:
2+
# Check that examples compile
3+
- sed -n '/``` cpp/,${/```$/q;/```/d;p}' README.md > main.cpp &&
4+
PYTHONPATH=mbed-os python mbed-os/tools/make.py -t GCC_ARM -m K82F
5+
--source=. --build=BUILD/K82F/GCC_ARM -j0 &&
6+
rm main.cpp
7+
- sed -n '/@code/,${/@endcode/q;/@/d;s/^ \*//;p}' I2CEEBlockDevice.h > main.cpp &&
8+
PYTHONPATH=mbed-os python mbed-os/tools/make.py -t GCC_ARM -m K82F
9+
--source=. --build=BUILD/K82F/GCC_ARM -j0 &&
10+
rm main.cpp
11+
12+
# Check that tests compile
13+
- rm -r BUILD && PYTHONPATH=mbed-os python mbed-os/tools/test.py
14+
-t GCC_ARM -m K82F --source=. --build=BUILD/TESTS/K82F/GCC_ARM -j0
15+
-n tests*
16+
17+
python:
18+
- "2.7"
19+
20+
install:
21+
# Get arm-none-eabi-gcc
22+
- sudo add-apt-repository -y ppa:terry.guo/gcc-arm-embedded
23+
- sudo apt-get update -qq
24+
- sudo apt-get install -qq gcc-arm-none-eabi --force-yes
25+
# Get dependencies
26+
- git clone https://github.com/armmbed/mbed-os.git
27+
# Install python dependencies
28+
- sudo pip install -r mbed-os/requirements.txt

I2CEEBlockDevice.h

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,37 @@
2424
* Microchip's 24LC or ATMEL's AT24C ranges
2525
*
2626
* @code
27+
* // Here's an example using a 24LC256 on a GR PEACH
2728
* #include "mbed.h"
2829
* #include "I2CEEBlockDevice.h"
29-
*
30-
* // Create 24LC device with 32Kbytes of memory
31-
* I2CEEBlockDevice flash(D14, D15, 0xa0, 32*1024);
32-
*
30+
*
31+
* // Create EEPROM device on I2C bus with 32kbytes of memory
32+
* I2CEEBlockDevice i2cee(D14, D15, 0xa0, 32*1024);
33+
*
3334
* int main() {
34-
* printf("flash test\n");
35-
* mx52r.init();
36-
* printf("flash size: %llu\n", flash.size());
37-
* printf("flash read size: %llu\n", flash.get_read_size());
38-
* printf("flash program size: %llu\n", flash.get_program_size());
39-
* printf("flash erase size: %llu\n", flash.get_erase_size());
40-
*
41-
* uint8_t *buffer = malloc(flash.get_erase_size());
35+
* printf("i2cee test\n");
36+
*
37+
* // Initialize the device and print the memory layout
38+
* i2cee.init();
39+
* printf("i2cee size: %llu\n", i2cee.size());
40+
* printf("i2cee read size: %llu\n", i2cee.get_read_size());
41+
* printf("i2cee program size: %llu\n", i2cee.get_program_size());
42+
* printf("i2cee erase size: %llu\n", i2cee.get_erase_size());
43+
*
44+
* // Write "Hello World!" to the first block
45+
* char *buffer = (char*)malloc(i2cee.get_erase_size());
4246
* sprintf(buffer, "Hello World!\n");
43-
* flash.erase(0, flash.get_erase_size());
44-
* flash.program(buffer, 0, flash.get_erase_size());
45-
* flash.read(buffer, 0, flash.get_erase_size());
47+
* i2cee.erase(0, i2cee.get_erase_size());
48+
* i2cee.program(buffer, 0, i2cee.get_erase_size());
49+
*
50+
* // Read back what was stored
51+
* i2cee.read(buffer, 0, i2cee.get_erase_size());
4652
* printf("%s", buffer);
47-
*
48-
* flash.deinit();
53+
*
54+
* // Deinitialize the device
55+
* i2cee.deinit();
4956
* }
57+
* @endcode
5058
*/
5159
class I2CEEBlockDevice : public BlockDevice {
5260
public:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ int main() {
2828
printf("i2cee erase size: %llu\n", i2cee.get_erase_size());
2929

3030
// Write "Hello World!" to the first block
31-
uint8_t *buffer = malloc(i2cee.get_erase_size());
31+
char *buffer = (char*)malloc(i2cee.get_erase_size());
3232
sprintf(buffer, "Hello World!\n");
3333
i2cee.erase(0, i2cee.get_erase_size());
3434
i2cee.program(buffer, 0, i2cee.get_erase_size());

0 commit comments

Comments
 (0)