[FL-85][FL-446][FL-720] Dallas key blanks and OneWire lib rework (#313)
* sepate one wire class * TM2004 writer * app mode write ds1990 * test another blanks protocol * new ibutton slave * one wire states * tim1 capture compare and update interrupts * interrupt mgr, new timers IRQ * discard HAL_TIM_PeriodElapsedCallback from main * add exti_14 line * add external interrupt callback * use int mgr in input * better interrupt managment * add interrupt callback enable and disable fns * properly init app * changed timings * rename one wire classes * use new owb classes * properly remove interrupts * new blanks writer * remove unused tests * new core includes * extern c guard * fix api_interrupt_remove usage * remove debug info, new way to detect blanks writing * remove copy constructor * change keys template * fix app sources recipe
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
#include "ibutton.h"
|
||||
#include "one_wire_gpio.h"
|
||||
#include "one_wire_master.h"
|
||||
#include "maxim_crc.h"
|
||||
|
||||
class AppiButtonModeDallasRead : public AppTemplateMode<AppiButtonState, AppiButtonEvent> {
|
||||
public:
|
||||
const char* name = "dallas read";
|
||||
AppiButton* app;
|
||||
OneWireGpio* onewire;
|
||||
OneWireMaster* onewire;
|
||||
|
||||
void event(AppiButtonEvent* event, AppiButtonState* state);
|
||||
void render(Canvas* canvas, AppiButtonState* state);
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
|
||||
// TODO open record
|
||||
const GpioPin* one_wire_pin_record = &ibutton_gpio;
|
||||
onewire = new OneWireGpio(one_wire_pin_record);
|
||||
onewire = new OneWireMaster(one_wire_pin_record);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -33,30 +33,17 @@ void AppiButtonModeDallasRead::event(AppiButtonEvent* event, AppiButtonState* st
|
||||
osKernelUnlock();
|
||||
|
||||
if(result) {
|
||||
printf("device on line\n");
|
||||
|
||||
delay(50);
|
||||
osKernelLock();
|
||||
__disable_irq();
|
||||
onewire->write(0x33);
|
||||
onewire->read_bytes(address, 8);
|
||||
__enable_irq();
|
||||
osKernelUnlock();
|
||||
|
||||
printf("address: %x", address[0]);
|
||||
for(uint8_t i = 1; i < 8; i++) {
|
||||
printf(":%x", address[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
printf("crc8: %x\n", maxim_crc8(address, 7));
|
||||
|
||||
if(maxim_crc8(address, 8) == 0) {
|
||||
printf("CRC valid\n");
|
||||
memcpy(app->state.dallas_address[app->state.dallas_address_index], address, 8);
|
||||
app->blink_green();
|
||||
} else {
|
||||
printf("CRC invalid\n");
|
||||
}
|
||||
} else {
|
||||
}
|
||||
} else if(event->type == AppiButtonEvent::EventTypeKey) {
|
||||
if(event->value.input.state && event->value.input.input == InputUp) {
|
||||
|
Reference in New Issue
Block a user