Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: ExioBufferdController MCP23S17 mbed-rtos mbed
main.cpp
- Committer:
- ryood
- Date:
- 2016-11-04
- Revision:
- 5:526691f54026
- Parent:
- 4:20ee7612edb9
- Child:
- 6:9acaeb5465d2
File content as of revision 5:526691f54026:
/*
* ExioBufferdController Test
*
* mbed: revison 121
* mbed-rtos: revision 117
*
* Created: 2016.11.05
*
*/
#include "mbed.h"
#include "rtos.h"
#include "ExioMcp23s17.h"
#include "ExioInBuffer.h"
#include "ExioBufferedIn.h"
#include "ExioBufferedRotaryEncoder.h"
SPI Spi(PC_12, PC_11, PC_10); // SPI3: mosi, miso, sclk
//SPI Spi(PA_7, PA_6, PA_5); // SPI1: mosi, miso, sclk
// MExioMcp23s17(int hardwareaddress, SPI& spi, PinName nCs, PinName nReset);
ExioMcp23s17 Exio(0x00, Spi, PD_2, PA_13);
void testExioInBuffer()
{
printf("*** Test ExioInBuffer ***\r\n");
// Reset MCP23S17 (初期化時にreset()が必要)
Exio.reset();
ExioInBuffer exioInBufferA(&Exio, ExioPortA);
ExioInBuffer exioInBufferB(&Exio, ExioPortB);
exioInBufferA.run(1);
exioInBufferB.run(1);
while (true) {
uint8_t va = exioInBufferA.readPort();
uint8_t vb = exioInBufferB.readPort();
printf("%d %d\r\n", va, vb);
//Thread::wait(10);
}
}
void testExioBufferedIn()
{
printf("*** Test ExioBuffedIn ***\r\n");
// Reset MCP23S17 (初期化時にreset()が必要)
Exio.reset();
ExioInBuffer inBufferA(&Exio, ExioPortA);
ExioBufferedIn inA[] = {
ExioBufferedIn(&inBufferA, 0),
ExioBufferedIn(&inBufferA, 1),
ExioBufferedIn(&inBufferA, 2),
ExioBufferedIn(&inBufferA, 3),
ExioBufferedIn(&inBufferA, 4),
ExioBufferedIn(&inBufferA, 5),
ExioBufferedIn(&inBufferA, 6),
ExioBufferedIn(&inBufferA, 7)
};
ExioInBuffer inBufferB(&Exio, ExioPortB);
ExioBufferedIn inB[] = {
ExioBufferedIn(&inBufferB, 0),
ExioBufferedIn(&inBufferB, 1),
ExioBufferedIn(&inBufferB, 2),
ExioBufferedIn(&inBufferB, 3),
ExioBufferedIn(&inBufferB, 4),
ExioBufferedIn(&inBufferB, 5),
ExioBufferedIn(&inBufferB, 6),
ExioBufferedIn(&inBufferB, 7)
};
inBufferA.run(10);
inBufferB.run(10);
while (true) {
for (int i = 0; i < 8; i++) {
int va = inA[i].read();
printf("%d ", va);
}
putchar(' ');
for (int i = 0; i < 8; i++) {
int vb = inB[i].read();
printf("%d ", vb);
}
printf("\r\n");
//Thread::wait(10);
}
}
void testExioBufferedRotaryEncoder()
{
printf("*** Test ExioBufferedRotaryEncoder ***\r\n");
// Reset MCP23S17 (初期化時にreset()が必要)
Exio.reset();
ExioInBuffer inBufferA(&Exio, ExioPortA);
ExioBufferedRotaryEncoder re1(&inBufferA, 0, 1);
// Start Timers
inBufferA.run(5);
re1.setInterval(1000);
while (true) {
int v = re1.getVal();
printf("%d\r\n", v);
}
}
int main()
{
//testExioInBuffer();
//testExioBufferedIn();
testExioBufferedRotaryEncoder();
}