pwm period is now 200us instead of the default 20ms veml6040 config is now AF_BIT | TRIG_BIT
Dependencies: mbed MMA8451Q USBDevice WakeUp vt100
Fork of afero_node_suntory_2017_06_15 by
spi/AferoCommHndlr.cpp@0:20bce0dcc921, 2016-12-20 (annotated)
- Committer:
- wataloh
- Date:
- Tue Dec 20 01:51:02 2016 +0000
- Revision:
- 0:20bce0dcc921
- Child:
- 1:b2a9a6f2c30e
kl25z teensy merged
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wataloh | 0:20bce0dcc921 | 1 | #include "AferoCommHndlr.h" |
wataloh | 0:20bce0dcc921 | 2 | |
wataloh | 0:20bce0dcc921 | 3 | static AferoCommHndlr *self = NULL; |
wataloh | 0:20bce0dcc921 | 4 | |
wataloh | 0:20bce0dcc921 | 5 | AferoCommHndlr::AferoCommHndlr() |
wataloh | 0:20bce0dcc921 | 6 | { |
wataloh | 0:20bce0dcc921 | 7 | } |
wataloh | 0:20bce0dcc921 | 8 | |
wataloh | 0:20bce0dcc921 | 9 | void |
wataloh | 0:20bce0dcc921 | 10 | AferoCommHndlr::loop() |
wataloh | 0:20bce0dcc921 | 11 | { |
wataloh | 0:20bce0dcc921 | 12 | piafLib->loop(); |
wataloh | 0:20bce0dcc921 | 13 | todoQ->loop(); |
wataloh | 0:20bce0dcc921 | 14 | } |
wataloh | 0:20bce0dcc921 | 15 | |
wataloh | 0:20bce0dcc921 | 16 | AferoCommHndlr* |
wataloh | 0:20bce0dcc921 | 17 | AferoCommHndlr::create(Timer *timer, mbedSPI *spi) |
wataloh | 0:20bce0dcc921 | 18 | { |
wataloh | 0:20bce0dcc921 | 19 | SERIAL_PRINT_DBG("HELLO\n"); |
wataloh | 0:20bce0dcc921 | 20 | self = new AferoCommHndlr(); |
wataloh | 0:20bce0dcc921 | 21 | self->timer = timer; |
wataloh | 0:20bce0dcc921 | 22 | self->piafLib = iafLib::create(SPI_SLAVE_INT, |
wataloh | 0:20bce0dcc921 | 23 | AferoCommHndlr::fco_irq_fall, |
wataloh | 0:20bce0dcc921 | 24 | AferoCommHndlr::myOnAttributeSet, |
wataloh | 0:20bce0dcc921 | 25 | AferoCommHndlr::myOnAttributeSetComplete, spi); |
wataloh | 0:20bce0dcc921 | 26 | self->todoQ = ToDoQ::create(AferoCommHndlr::onGetTodo); |
wataloh | 0:20bce0dcc921 | 27 | SERIAL_PRINT_DBG("AferoCommHndlr init done\n"); |
wataloh | 0:20bce0dcc921 | 28 | return self; |
wataloh | 0:20bce0dcc921 | 29 | } |
wataloh | 0:20bce0dcc921 | 30 | |
wataloh | 0:20bce0dcc921 | 31 | void |
wataloh | 0:20bce0dcc921 | 32 | AferoCommHndlr::myOnAttributeSet( |
wataloh | 0:20bce0dcc921 | 33 | const uint8_t requestId, |
wataloh | 0:20bce0dcc921 | 34 | const uint16_t attributeId, |
wataloh | 0:20bce0dcc921 | 35 | const uint16_t valueLen, |
wataloh | 0:20bce0dcc921 | 36 | const uint8_t *value) |
wataloh | 0:20bce0dcc921 | 37 | { |
wataloh | 0:20bce0dcc921 | 38 | self->piafLib->setAttributeComplete(requestId, attributeId, valueLen, value); |
wataloh | 0:20bce0dcc921 | 39 | } |
wataloh | 0:20bce0dcc921 | 40 | |
wataloh | 0:20bce0dcc921 | 41 | void |
wataloh | 0:20bce0dcc921 | 42 | AferoCommHndlr::myOnAttributeSetComplete( |
wataloh | 0:20bce0dcc921 | 43 | const uint8_t requestId, |
wataloh | 0:20bce0dcc921 | 44 | const uint16_t attributeId, |
wataloh | 0:20bce0dcc921 | 45 | const uint16_t valueLen, |
wataloh | 0:20bce0dcc921 | 46 | const uint8_t *value) |
wataloh | 0:20bce0dcc921 | 47 | { |
wataloh | 0:20bce0dcc921 | 48 | if(attributeId==ATTR_ID_SENSING_INTERVAL) |
wataloh | 0:20bce0dcc921 | 49 | { |
wataloh | 0:20bce0dcc921 | 50 | |
wataloh | 0:20bce0dcc921 | 51 | } |
wataloh | 0:20bce0dcc921 | 52 | else if(attributeId==ATTR_ID_SENSE_VAL) |
wataloh | 0:20bce0dcc921 | 53 | { |
wataloh | 0:20bce0dcc921 | 54 | //self->timeoutUpload.attach(&AferoCommHndlr::updateToAferoCloud,1); |
wataloh | 0:20bce0dcc921 | 55 | } |
wataloh | 0:20bce0dcc921 | 56 | } |
wataloh | 0:20bce0dcc921 | 57 | |
wataloh | 0:20bce0dcc921 | 58 | void |
wataloh | 0:20bce0dcc921 | 59 | AferoCommHndlr::fco_irq_fall() |
wataloh | 0:20bce0dcc921 | 60 | { |
wataloh | 0:20bce0dcc921 | 61 | if(self->piafLib) |
wataloh | 0:20bce0dcc921 | 62 | { |
wataloh | 0:20bce0dcc921 | 63 | self->piafLib->mcuISR(); |
wataloh | 0:20bce0dcc921 | 64 | } |
wataloh | 0:20bce0dcc921 | 65 | } |
wataloh | 0:20bce0dcc921 | 66 | |
wataloh | 0:20bce0dcc921 | 67 | void |
wataloh | 0:20bce0dcc921 | 68 | AferoCommHndlr::onGetTodo(ToDo *todo) |
wataloh | 0:20bce0dcc921 | 69 | { |
wataloh | 0:20bce0dcc921 | 70 | SERIAL_PRINT_DBG("AferoCommHndlr::onGetTodo()\n"); |
wataloh | 0:20bce0dcc921 | 71 | char buf[255]; |
wataloh | 0:20bce0dcc921 | 72 | memset(buf,'\0',sizeof(buf)); |
wataloh | 0:20bce0dcc921 | 73 | if(todo!=NULL) |
wataloh | 0:20bce0dcc921 | 74 | { |
wataloh | 0:20bce0dcc921 | 75 | todo->toJSON(buf); |
wataloh | 0:20bce0dcc921 | 76 | SERIAL_PRINT_DBG("%s\n",buf); |
wataloh | 0:20bce0dcc921 | 77 | self->piafLib->setAttribute(ATTR_ID_SENSE_VAL,strlen(buf),buf); |
wataloh | 0:20bce0dcc921 | 78 | } |
wataloh | 0:20bce0dcc921 | 79 | } |
wataloh | 0:20bce0dcc921 | 80 | /* |
wataloh | 0:20bce0dcc921 | 81 | void |
wataloh | 0:20bce0dcc921 | 82 | AferoCommHndlr::onGetTodo(ToDo *todo) |
wataloh | 0:20bce0dcc921 | 83 | { |
wataloh | 0:20bce0dcc921 | 84 | char buf[255]; |
wataloh | 0:20bce0dcc921 | 85 | memset(buf,'\0',sizeof(buf)); |
wataloh | 0:20bce0dcc921 | 86 | if(todo!=NULL) |
wataloh | 0:20bce0dcc921 | 87 | { |
wataloh | 0:20bce0dcc921 | 88 | todo->toJSON(buf); |
wataloh | 0:20bce0dcc921 | 89 | SERIAL_PRINT_DBG("%s\n",buf); |
wataloh | 0:20bce0dcc921 | 90 | self->piafLib->setAttribute(ATTR_ID_SENSE_VAL,strlen(buf),buf); |
wataloh | 0:20bce0dcc921 | 91 | } |
wataloh | 0:20bce0dcc921 | 92 | } |
wataloh | 0:20bce0dcc921 | 93 | */ |