Release candidate version. The pointer in GAS Pressure display is changed to a triangle.
Dependencies: UniGraphic mbed vt100
Please note, at 2-Mar-2018 the current version of mbed-lib has a defect in Ticker.
https://os.mbed.com/forum/bugs-suggestions/topic/29287/
So, mbed lib version 157 is intentionally being used.
Please do not update mbed library until the problem in the above URL is fixed.
In this version, format of GAS Pressure Display has been changed.
moto
af_utils/mbedSPI.cpp@0:774324cbc5a6, 2018-03-02 (annotated)
- Committer:
- Rhyme
- Date:
- Fri Mar 02 07:56:09 2018 +0000
- Revision:
- 0:774324cbc5a6
Release candidate version. GAS Pressure pointer is now a triangle.; Some source file clean-up was done.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:774324cbc5a6 | 1 | #include "mbed.h" |
Rhyme | 0:774324cbc5a6 | 2 | #include "vt100.h" |
Rhyme | 0:774324cbc5a6 | 3 | #include "afSPI.h" |
Rhyme | 0:774324cbc5a6 | 4 | #include "mbedSPI.h" |
Rhyme | 0:774324cbc5a6 | 5 | |
Rhyme | 0:774324cbc5a6 | 6 | #if defined (TARGET_KL25Z) || defined (TARGET_TEENSY3_1) |
Rhyme | 0:774324cbc5a6 | 7 | #ifndef SPI0_C1 |
Rhyme | 0:774324cbc5a6 | 8 | #define SPI0_C1 (*(uint8_t *)0x40076000) |
Rhyme | 0:774324cbc5a6 | 9 | #endif |
Rhyme | 0:774324cbc5a6 | 10 | #endif |
Rhyme | 0:774324cbc5a6 | 11 | /* |
Rhyme | 0:774324cbc5a6 | 12 | class mbedSPI : public afSPI { |
Rhyme | 0:774324cbc5a6 | 13 | public: |
Rhyme | 0:774324cbc5a6 | 14 | mbedSPI(PinName mosi, PinName miso, PinName sckl, PinName cs) ; |
Rhyme | 0:774324cbc5a6 | 15 | virtual void begin() ; |
Rhyme | 0:774324cbc5a6 | 16 | virtual void beginSPI() ; |
Rhyme | 0:774324cbc5a6 | 17 | virtual void endSPI() ; |
Rhyme | 0:774324cbc5a6 | 18 | virtual void transfer(char *bytes,int len) ; |
Rhyme | 0:774324cbc5a6 | 19 | private: |
Rhyme | 0:774324cbc5a6 | 20 | SPI _spi ; |
Rhyme | 0:774324cbc5a6 | 21 | DigitalOut _cs ; |
Rhyme | 0:774324cbc5a6 | 22 | } ; |
Rhyme | 0:774324cbc5a6 | 23 | */ |
Rhyme | 0:774324cbc5a6 | 24 | |
Rhyme | 0:774324cbc5a6 | 25 | mbedSPI::mbedSPI(PinName mosi, PinName miso, PinName sckl, PinName cs) : |
Rhyme | 0:774324cbc5a6 | 26 | _spi(mosi, miso, sckl), _cs(cs, 1) |
Rhyme | 0:774324cbc5a6 | 27 | { |
Rhyme | 0:774324cbc5a6 | 28 | _spi.format(8, 0) ; |
Rhyme | 0:774324cbc5a6 | 29 | _spi.frequency(1000000) ; /* 1MHz */ |
Rhyme | 0:774324cbc5a6 | 30 | |
Rhyme | 0:774324cbc5a6 | 31 | #if defined (TARGET_KL25Z) || defined (TARGET_TEENSY3_1) |
Rhyme | 0:774324cbc5a6 | 32 | #ifndef SPI0_C1 |
Rhyme | 0:774324cbc5a6 | 33 | #define SPI0_C1 (*(uint8_t *)0x40076000) |
Rhyme | 0:774324cbc5a6 | 34 | #endif |
Rhyme | 0:774324cbc5a6 | 35 | // SPI0_C1 |= 0x01 ; /* LSB First */ |
Rhyme | 0:774324cbc5a6 | 36 | // SPI0_C1 &= 0xFE ; /* MSB First */ |
Rhyme | 0:774324cbc5a6 | 37 | #endif |
Rhyme | 0:774324cbc5a6 | 38 | |
Rhyme | 0:774324cbc5a6 | 39 | } |
Rhyme | 0:774324cbc5a6 | 40 | |
Rhyme | 0:774324cbc5a6 | 41 | void mbedSPI::begin(void) |
Rhyme | 0:774324cbc5a6 | 42 | { |
Rhyme | 0:774324cbc5a6 | 43 | } |
Rhyme | 0:774324cbc5a6 | 44 | |
Rhyme | 0:774324cbc5a6 | 45 | void mbedSPI::beginSPI() |
Rhyme | 0:774324cbc5a6 | 46 | { |
Rhyme | 0:774324cbc5a6 | 47 | // printf("+") ; fflush(stdout) ; |
Rhyme | 0:774324cbc5a6 | 48 | _cs = 0 ; |
Rhyme | 0:774324cbc5a6 | 49 | SPI0_C1 |= 0x01 ; /* LSB First */ |
Rhyme | 0:774324cbc5a6 | 50 | wait_us(1) ; |
Rhyme | 0:774324cbc5a6 | 51 | } |
Rhyme | 0:774324cbc5a6 | 52 | |
Rhyme | 0:774324cbc5a6 | 53 | void mbedSPI::endSPI() |
Rhyme | 0:774324cbc5a6 | 54 | { |
Rhyme | 0:774324cbc5a6 | 55 | _cs = 1 ; |
Rhyme | 0:774324cbc5a6 | 56 | SPI0_C1 &= 0xFE ; /* MSB First */ |
Rhyme | 0:774324cbc5a6 | 57 | wait_us(1) ; |
Rhyme | 0:774324cbc5a6 | 58 | // printf("-") ; fflush(stdout) ; |
Rhyme | 0:774324cbc5a6 | 59 | } |
Rhyme | 0:774324cbc5a6 | 60 | |
Rhyme | 0:774324cbc5a6 | 61 | /** |
Rhyme | 0:774324cbc5a6 | 62 | * on 17-Jan-2018 disable/enable irq added |
Rhyme | 0:774324cbc5a6 | 63 | * before and after of each _spi.writes |
Rhyme | 0:774324cbc5a6 | 64 | */ |
Rhyme | 0:774324cbc5a6 | 65 | void mbedSPI::transfer(char *bytes, int len) |
Rhyme | 0:774324cbc5a6 | 66 | { |
Rhyme | 0:774324cbc5a6 | 67 | int i ; |
Rhyme | 0:774324cbc5a6 | 68 | for (i = 0 ; i < len ; i++ ) { |
Rhyme | 0:774324cbc5a6 | 69 | __disable_irq() ; // Disable Interrupts |
Rhyme | 0:774324cbc5a6 | 70 | bytes[i] = _spi.write(bytes[i]) ; |
Rhyme | 0:774324cbc5a6 | 71 | __enable_irq() ; // Enable Interrupts |
Rhyme | 0:774324cbc5a6 | 72 | } |
Rhyme | 0:774324cbc5a6 | 73 | } |
Rhyme | 0:774324cbc5a6 | 74 |