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.
ExioInBuffer.h
00001 /* 00002 * ExioInBuffer.h 00003 * 00004 * Created: 2016.11.05 00005 * 00006 */ 00007 00008 #ifndef _EXIOINBUFFER_H_ 00009 #define _EXIOINBUFFER_H_ 00010 00011 #include "mbed.h" 00012 #include "rtos.h" 00013 #include "ExioMcp23s17.h" 00014 00015 class ExioInBuffer { 00016 public: 00017 ExioInBuffer(ExioMcp23s17* device, ExioPort port) : 00018 _device(device), 00019 _port(port), 00020 _buffer(0x00), 00021 _timer(&ExioInBuffer::threadHelper, osTimerPeriodic, (void *)this) 00022 { 00023 // set the port as input 00024 _device->ioDirection(_port, 0xff); 00025 _device->ioPullup(_port, 0xff); 00026 _device->ioPolarity(_port, 0xff); 00027 } 00028 00029 uint8_t readPort() 00030 { 00031 return _buffer; 00032 } 00033 00034 void run(uint32_t millsec) 00035 { 00036 _timer.start(millsec); 00037 } 00038 00039 void stop() 00040 { 00041 _timer.stop(); 00042 } 00043 00044 protected: 00045 ExioMcp23s17* _device; 00046 ExioPort _port; 00047 uint8_t _buffer; 00048 RtosTimer _timer; 00049 00050 static void threadHelper(const void* arg) 00051 { 00052 ExioInBuffer* instance = (ExioInBuffer*)arg; 00053 instance->update(); 00054 } 00055 00056 void update() { 00057 _buffer = _device->readPort(_port); 00058 } 00059 }; 00060 00061 #endif //_EXIOINBUFFER_H_
Generated on Sat Jul 16 2022 02:09:56 by
1.7.2