Toyomasa Watarai
/
Hello-FM25W256
Hello program for the FM25W256 library
main.cpp@1:be908b1aafe6, 2016-03-04 (annotated)
- Committer:
- MACRUM
- Date:
- Fri Mar 04 15:50:11 2016 +0000
- Revision:
- 1:be908b1aafe6
- Parent:
- 0:3efb18460968
- Child:
- 2:980e3d46d20e
Use FM25W256 class library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MACRUM | 0:3efb18460968 | 1 | #include "mbed.h" |
MACRUM | 1:be908b1aafe6 | 2 | #include "FM25W256.h" |
MACRUM | 0:3efb18460968 | 3 | |
MACRUM | 0:3efb18460968 | 4 | Serial pc(USBTX, USBRX); |
MACRUM | 1:be908b1aafe6 | 5 | FM25W256 f_ram(dp2, dp1, dp6, dp18); |
MACRUM | 0:3efb18460968 | 6 | |
MACRUM | 0:3efb18460968 | 7 | void read_test() |
MACRUM | 0:3efb18460968 | 8 | { |
MACRUM | 0:3efb18460968 | 9 | uint16_t adrs = 0; |
MACRUM | 0:3efb18460968 | 10 | for(int i=0; i<16; i++) { |
MACRUM | 0:3efb18460968 | 11 | pc.printf("0x%04X : ", i * 16); |
MACRUM | 0:3efb18460968 | 12 | for(int j=0; j<16; j++) { |
MACRUM | 1:be908b1aafe6 | 13 | pc.printf("%02X ", f_ram.read(adrs++)); |
MACRUM | 0:3efb18460968 | 14 | } |
MACRUM | 0:3efb18460968 | 15 | pc.printf("\n"); |
MACRUM | 0:3efb18460968 | 16 | } |
MACRUM | 0:3efb18460968 | 17 | } |
MACRUM | 0:3efb18460968 | 18 | |
MACRUM | 0:3efb18460968 | 19 | void write_test() |
MACRUM | 0:3efb18460968 | 20 | { |
MACRUM | 1:be908b1aafe6 | 21 | uint8_t buf[16]; |
MACRUM | 1:be908b1aafe6 | 22 | for(int i=0; i<16; i++) { |
MACRUM | 1:be908b1aafe6 | 23 | buf[i] = (15 - i); |
MACRUM | 0:3efb18460968 | 24 | } |
MACRUM | 1:be908b1aafe6 | 25 | f_ram.write(0, buf, 16); |
MACRUM | 0:3efb18460968 | 26 | } |
MACRUM | 0:3efb18460968 | 27 | |
MACRUM | 0:3efb18460968 | 28 | int main() |
MACRUM | 0:3efb18460968 | 29 | { |
MACRUM | 0:3efb18460968 | 30 | pc.printf("\nFM25W256 test program - write test? (y/n) "); |
MACRUM | 0:3efb18460968 | 31 | if (pc.getc() == 'y') { |
MACRUM | 0:3efb18460968 | 32 | write_test(); |
MACRUM | 0:3efb18460968 | 33 | } |
MACRUM | 0:3efb18460968 | 34 | |
MACRUM | 0:3efb18460968 | 35 | pc.printf("\nFM25W256 test program - read test? (y/n) "); |
MACRUM | 0:3efb18460968 | 36 | if (pc.getc() == 'y') { |
MACRUM | 0:3efb18460968 | 37 | pc.printf("\n"); |
MACRUM | 0:3efb18460968 | 38 | read_test(); |
MACRUM | 0:3efb18460968 | 39 | } |
MACRUM | 0:3efb18460968 | 40 | |
MACRUM | 0:3efb18460968 | 41 | while(1) { |
MACRUM | 0:3efb18460968 | 42 | } |
MACRUM | 0:3efb18460968 | 43 | } |