Added a GPIO to power on/off for external I2C sensor(s) (with LEDs)

Dependencies:   UniGraphic mbed vt100

18-Jun-2018 外部センサの電源オン・オフ機能は下位互換の為に無効になっていました。 この版で再度有効にしました。

Committer:
Rhyme
Date:
Mon Jun 18 01:56:00 2018 +0000
Revision:
1:8d65cfc3a2e2
Parent:
0:846e2321c637
External sensor power on/off function enabled. (Previously disabled)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:846e2321c637 1 #include "mbed.h"
Rhyme 0:846e2321c637 2 #include "edge_time.h"
Rhyme 0:846e2321c637 3 #include "pending.h"
Rhyme 0:846e2321c637 4
Rhyme 0:846e2321c637 5 /*
Rhyme 0:846e2321c637 6 class pending_class {
Rhyme 0:846e2321c637 7 public:
Rhyme 0:846e2321c637 8 pending_class() ;
Rhyme 0:846e2321c637 9 ~pending_class() ;
Rhyme 0:846e2321c637 10
Rhyme 0:846e2321c637 11 request_t *request ;
Rhyme 0:846e2321c637 12 uint32_t submit_time ;
Rhyme 0:846e2321c637 13 uint32_t replied_time ;
Rhyme 0:846e2321c637 14 } ;
Rhyme 0:846e2321c637 15 */
Rhyme 0:846e2321c637 16
Rhyme 0:846e2321c637 17 pending_class::pending_class()
Rhyme 0:846e2321c637 18 {
Rhyme 0:846e2321c637 19 submit_time = edge_time ; /* save current time */
Rhyme 0:846e2321c637 20 replied_time = 0 ;
Rhyme 0:846e2321c637 21 request = new request_t ;
Rhyme 0:846e2321c637 22 request->messageType = 0 ;
Rhyme 0:846e2321c637 23 request->attrId = 0 ;
Rhyme 0:846e2321c637 24 request->requestId = 0 ;
Rhyme 0:846e2321c637 25 request->valueLen = 0 ;
Rhyme 0:846e2321c637 26 request->p_value = new uint8_t[256] ;
Rhyme 0:846e2321c637 27 }
Rhyme 0:846e2321c637 28
Rhyme 0:846e2321c637 29 pending_class::pending_class(
Rhyme 0:846e2321c637 30 uint8_t messageType,
Rhyme 0:846e2321c637 31 uint16_t attrId,
Rhyme 0:846e2321c637 32 uint8_t requestId,
Rhyme 0:846e2321c637 33 uint16_t valueLen,
Rhyme 0:846e2321c637 34 uint8_t *value
Rhyme 0:846e2321c637 35 )
Rhyme 0:846e2321c637 36 {
Rhyme 0:846e2321c637 37 submit_time = edge_time ; /* save current time */
Rhyme 0:846e2321c637 38 replied_time = 0 ;
Rhyme 0:846e2321c637 39 request = new request_t ;
Rhyme 0:846e2321c637 40 request->p_value = new uint8_t[256] ;
Rhyme 0:846e2321c637 41 request->messageType = messageType ;
Rhyme 0:846e2321c637 42 request->attrId = attrId ;
Rhyme 0:846e2321c637 43 request->requestId = requestId ;
Rhyme 0:846e2321c637 44 request->valueLen = valueLen ;
Rhyme 0:846e2321c637 45 memcpy(request->p_value, value, valueLen) ;
Rhyme 0:846e2321c637 46 }
Rhyme 0:846e2321c637 47
Rhyme 0:846e2321c637 48 pending_class::~pending_class()
Rhyme 0:846e2321c637 49 {
Rhyme 0:846e2321c637 50 submit_time = 0 ;
Rhyme 0:846e2321c637 51 replied_time = 0 ;
Rhyme 0:846e2321c637 52 delete [] request->p_value ;
Rhyme 0:846e2321c637 53 request->p_value = 0 ;
Rhyme 0:846e2321c637 54 delete request ;
Rhyme 0:846e2321c637 55 }