Merge remote-tracking branch 'origin/dev' into release-candidate
This commit is contained in:
		
						commit
						5a0f7e20ba
					
				
							
								
								
									
										1
									
								
								Brewfile
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								Brewfile
									
									
									
									
									
								
							| @ -4,3 +4,4 @@ brew "heatshrink" | ||||
| brew "open-ocd" | ||||
| brew "clang-format" | ||||
| brew "dfu-util" | ||||
| brew "imagemagick" | ||||
| @ -312,7 +312,7 @@ static void code_input_view_draw_callback(Canvas* canvas, void* _model) { | ||||
|             44 + y_offset, | ||||
|             model->current); | ||||
| 
 | ||||
|         if(model->current) canvas_draw_str(canvas, 2, 39 - y_offset, "Repeat code"); | ||||
|         if(model->current) canvas_draw_str(canvas, 2, 39 + y_offset, "Repeat code"); | ||||
| 
 | ||||
|         break; | ||||
|     default: | ||||
|  | ||||
| @ -17,6 +17,9 @@ void KeyEmulator::start(iButtonKey* key) { | ||||
|     anything_emulated = false; | ||||
|     stop(); | ||||
| 
 | ||||
|     // pulldown pull pin, to prevent low-pass filtering by the RFID part of the schematic
 | ||||
|     furi_hal_rfid_pin_pull_pulldown(); | ||||
| 
 | ||||
|     switch(key->get_key_type()) { | ||||
|     case iButtonKeyType::KeyDallas: | ||||
|         start_dallas_emulate(key); | ||||
| @ -44,6 +47,7 @@ bool KeyEmulator::emulated() { | ||||
| void KeyEmulator::stop() { | ||||
|     onewire_slave->stop(); | ||||
|     pulser.stop(); | ||||
|     furi_hal_rfid_pins_reset(); | ||||
| } | ||||
| 
 | ||||
| void KeyEmulator::start_cyfral_emulate(iButtonKey* key) { | ||||
|  | ||||
| @ -115,12 +115,10 @@ bool KeyReader::verify_key(iButtonKeyType key_type, const uint8_t* const data, u | ||||
| } | ||||
| 
 | ||||
| void KeyReader::start_comaparator(void) { | ||||
|     // pulldown lf-rfid pins to prevent interference
 | ||||
|     hal_gpio_init(&gpio_rfid_pull, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); | ||||
|     hal_gpio_write(&gpio_rfid_pull, false); | ||||
|     furi_hal_rfid_pins_reset(); | ||||
| 
 | ||||
|     hal_gpio_init(&gpio_rfid_carrier_out, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); | ||||
|     hal_gpio_write(&gpio_rfid_carrier_out, false); | ||||
|     // pulldown pull pin, we sense the signal through the analog part of the RFID schematic
 | ||||
|     furi_hal_rfid_pin_pull_pulldown(); | ||||
| 
 | ||||
|     comparator_callback_pointer = | ||||
|         cbc::obtain_connector(this, &KeyReader::comparator_trigger_callback); | ||||
| @ -130,6 +128,11 @@ void KeyReader::start_comaparator(void) { | ||||
| } | ||||
| 
 | ||||
| void KeyReader::stop_comaparator(void) { | ||||
|     furi_hal_rfid_pins_reset(); | ||||
| 
 | ||||
|     // rfid_pins_reset will disable ibutton pin
 | ||||
|     furi_hal_ibutton_start(); | ||||
| 
 | ||||
|     HAL_COMP_Stop(&hcomp1); | ||||
|     api_interrupt_remove(comparator_callback_pointer, InterruptTypeComparatorTrigger); | ||||
| } | ||||
|  | ||||
| @ -56,7 +56,7 @@ void PulseSequencer::init_timer(uint32_t period) { | ||||
| 
 | ||||
|     HAL_NVIC_EnableIRQ(TIM1_UP_TIM16_IRQn); | ||||
| 
 | ||||
|     hal_gpio_init(&ibutton_gpio, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); | ||||
|     hal_gpio_init(&ibutton_gpio, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedVeryHigh); | ||||
| } | ||||
| 
 | ||||
| void PulseSequencer::deinit_timer() { | ||||
|  | ||||
| @ -92,6 +92,37 @@ void input_cli_send(Cli* cli, string_t args, void* context) { | ||||
|     furi_pubsub_publish(input->event_pubsub, &event); | ||||
| } | ||||
| 
 | ||||
| static void input_cli_dump_events_callback(const void* value, void* ctx) { | ||||
|     furi_assert(value); | ||||
|     furi_assert(ctx); | ||||
|     osMessageQueueId_t input_queue = ctx; | ||||
|     osMessageQueuePut(input_queue, value, 0, osWaitForever); | ||||
| } | ||||
| 
 | ||||
| static void input_cli_dump(Cli* cli, string_t args, void* context) { | ||||
|     osMessageQueueId_t input_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); | ||||
|     FuriPubSubSubscription* input_subscription = | ||||
|         furi_pubsub_subscribe(input->event_pubsub, input_cli_dump_events_callback, input_queue); | ||||
| 
 | ||||
|     bool stop = false; | ||||
|     InputEvent input_event; | ||||
|     while(!stop) { | ||||
|         if(osMessageQueueGet(input_queue, &input_event, NULL, 100) == osOK) { | ||||
|             printf( | ||||
|                 "key: %s type: %s\r\n", | ||||
|                 input_get_key_name(input_event.key), | ||||
|                 input_get_type_name(input_event.type)); | ||||
|         } | ||||
| 
 | ||||
|         if(cli_cmd_interrupt_received(cli)) { | ||||
|             stop = true; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     furi_pubsub_unsubscribe(input->event_pubsub, input_subscription); | ||||
|     osMessageQueueDelete(input_queue); | ||||
| } | ||||
| 
 | ||||
| const char* input_get_key_name(InputKey key) { | ||||
|     for(size_t i = 0; i < input_pins_count; i++) { | ||||
|         if(input_pins[i].key == key) { | ||||
| @ -126,7 +157,9 @@ int32_t input_srv() { | ||||
|     input->cli = furi_record_open("cli"); | ||||
|     if(input->cli) { | ||||
|         cli_add_command( | ||||
|             input->cli, "input_send", CliCommandFlagParallelSafe, input_cli_send, input); | ||||
|             input->cli, "input_send", CliCommandFlagParallelSafe, input_cli_send, NULL); | ||||
|         cli_add_command( | ||||
|             input->cli, "input_dump", CliCommandFlagParallelSafe, input_cli_dump, NULL); | ||||
|     } | ||||
| 
 | ||||
|     input->pin_states = furi_alloc(input_pins_count * sizeof(InputPinState)); | ||||
|  | ||||
| @ -37,7 +37,9 @@ void RfidWriter::start() { | ||||
|     furi_hal_rfid_tim_read(125000, 0.5); | ||||
|     furi_hal_rfid_pins_read(); | ||||
|     furi_hal_rfid_tim_read_start(); | ||||
|     hal_gpio_write(&gpio_rfid_pull, true); | ||||
| 
 | ||||
|     // do not ground the antenna
 | ||||
|     furi_hal_rfid_pin_pull_release(); | ||||
| } | ||||
| 
 | ||||
| void RfidWriter::stop() { | ||||
|  | ||||
| @ -3,6 +3,7 @@ | ||||
| #include "status.pb.h" | ||||
| 
 | ||||
| #include <furi-hal-info.h> | ||||
| #include <furi-hal-bootloader.h> | ||||
| #include <power/power_service/power.h> | ||||
| 
 | ||||
| void rpc_system_system_ping_process(const PB_Main* msg_request, void* context) { | ||||
| @ -98,6 +99,15 @@ void rpc_system_system_device_info_process(const PB_Main* request, void* context | ||||
|     free(response); | ||||
| } | ||||
| 
 | ||||
| void rpc_system_system_factory_reset_process(const PB_Main* request, void* context) { | ||||
|     furi_assert(request); | ||||
|     furi_assert(request->which_content == PB_Main_system_factory_reset_request_tag); | ||||
|     furi_assert(context); | ||||
| 
 | ||||
|     furi_hal_bootloader_set_flags(FuriHalBootloaderFlagFactoryReset); | ||||
|     power_reboot(PowerBootModeNormal); | ||||
| } | ||||
| 
 | ||||
| void* rpc_system_system_alloc(Rpc* rpc) { | ||||
|     RpcHandler rpc_handler = { | ||||
|         .message_handler = NULL, | ||||
| @ -114,5 +124,8 @@ void* rpc_system_system_alloc(Rpc* rpc) { | ||||
|     rpc_handler.message_handler = rpc_system_system_device_info_process; | ||||
|     rpc_add_handler(rpc, PB_Main_system_device_info_request_tag, &rpc_handler); | ||||
| 
 | ||||
|     rpc_handler.message_handler = rpc_system_system_factory_reset_process; | ||||
|     rpc_add_handler(rpc, PB_Main_system_factory_reset_request_tag, &rpc_handler); | ||||
| 
 | ||||
|     return NULL; | ||||
| } | ||||
|  | ||||
| @ -91,6 +91,7 @@ typedef struct _PB_Main { | ||||
|         PB_System_RebootRequest system_reboot_request; | ||||
|         PB_System_DeviceInfoRequest system_device_info_request; | ||||
|         PB_System_DeviceInfoResponse system_device_info_response; | ||||
|         PB_System_FactoryResetRequest system_factory_reset_request; | ||||
|     } content;  | ||||
| } PB_Main; | ||||
| 
 | ||||
| @ -147,6 +148,7 @@ extern "C" { | ||||
| #define PB_Main_system_reboot_request_tag        31 | ||||
| #define PB_Main_system_device_info_request_tag   32 | ||||
| #define PB_Main_system_device_info_response_tag  33 | ||||
| #define PB_Main_system_factory_reset_request_tag 34 | ||||
| 
 | ||||
| /* Struct field encoding specification for nanopb */ | ||||
| #define PB_Empty_FIELDLIST(X, a) \ | ||||
| @ -192,7 +194,8 @@ X(a, STATIC,   ONEOF,    MSG_W_CB, (content,storage_info_response,content.storag | ||||
| X(a, STATIC,   ONEOF,    MSG_W_CB, (content,storage_rename_request,content.storage_rename_request),  30) \ | ||||
| X(a, STATIC,   ONEOF,    MSG_W_CB, (content,system_reboot_request,content.system_reboot_request),  31) \ | ||||
| X(a, STATIC,   ONEOF,    MSG_W_CB, (content,system_device_info_request,content.system_device_info_request),  32) \ | ||||
| X(a, STATIC,   ONEOF,    MSG_W_CB, (content,system_device_info_response,content.system_device_info_response),  33) | ||||
| X(a, STATIC,   ONEOF,    MSG_W_CB, (content,system_device_info_response,content.system_device_info_response),  33) \ | ||||
| X(a, STATIC,   ONEOF,    MSG_W_CB, (content,system_factory_reset_request,content.system_factory_reset_request),  34) | ||||
| #define PB_Main_CALLBACK NULL | ||||
| #define PB_Main_DEFAULT NULL | ||||
| #define PB_Main_content_empty_MSGTYPE PB_Empty | ||||
| @ -225,6 +228,7 @@ X(a, STATIC,   ONEOF,    MSG_W_CB, (content,system_device_info_response,content. | ||||
| #define PB_Main_content_system_reboot_request_MSGTYPE PB_System_RebootRequest | ||||
| #define PB_Main_content_system_device_info_request_MSGTYPE PB_System_DeviceInfoRequest | ||||
| #define PB_Main_content_system_device_info_response_MSGTYPE PB_System_DeviceInfoResponse | ||||
| #define PB_Main_content_system_factory_reset_request_MSGTYPE PB_System_FactoryResetRequest | ||||
| 
 | ||||
| extern const pb_msgdesc_t PB_Empty_msg; | ||||
| extern const pb_msgdesc_t PB_StopSession_msg; | ||||
|  | ||||
| @ -21,5 +21,8 @@ PB_BIND(PB_System_DeviceInfoRequest, PB_System_DeviceInfoRequest, AUTO) | ||||
| PB_BIND(PB_System_DeviceInfoResponse, PB_System_DeviceInfoResponse, AUTO) | ||||
| 
 | ||||
| 
 | ||||
| PB_BIND(PB_System_FactoryResetRequest, PB_System_FactoryResetRequest, AUTO) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -25,6 +25,10 @@ typedef struct _PB_System_DeviceInfoResponse { | ||||
|     char *value;  | ||||
| } PB_System_DeviceInfoResponse; | ||||
| 
 | ||||
| typedef struct _PB_System_FactoryResetRequest {  | ||||
|     char dummy_field; | ||||
| } PB_System_FactoryResetRequest; | ||||
| 
 | ||||
| typedef struct _PB_System_PingRequest {  | ||||
|     pb_bytes_array_t *data;  | ||||
| } PB_System_PingRequest; | ||||
| @ -54,11 +58,13 @@ extern "C" { | ||||
| #define PB_System_RebootRequest_init_default     {_PB_System_RebootRequest_RebootMode_MIN} | ||||
| #define PB_System_DeviceInfoRequest_init_default {0} | ||||
| #define PB_System_DeviceInfoResponse_init_default {NULL, NULL} | ||||
| #define PB_System_FactoryResetRequest_init_default {0} | ||||
| #define PB_System_PingRequest_init_zero          {NULL} | ||||
| #define PB_System_PingResponse_init_zero         {NULL} | ||||
| #define PB_System_RebootRequest_init_zero        {_PB_System_RebootRequest_RebootMode_MIN} | ||||
| #define PB_System_DeviceInfoRequest_init_zero    {0} | ||||
| #define PB_System_DeviceInfoResponse_init_zero   {NULL, NULL} | ||||
| #define PB_System_FactoryResetRequest_init_zero  {0} | ||||
| 
 | ||||
| /* Field tags (for use in manual encoding/decoding) */ | ||||
| #define PB_System_DeviceInfoResponse_key_tag     1 | ||||
| @ -94,11 +100,17 @@ X(a, POINTER,  SINGULAR, STRING,   value,             2) | ||||
| #define PB_System_DeviceInfoResponse_CALLBACK NULL | ||||
| #define PB_System_DeviceInfoResponse_DEFAULT NULL | ||||
| 
 | ||||
| #define PB_System_FactoryResetRequest_FIELDLIST(X, a) \ | ||||
| 
 | ||||
| #define PB_System_FactoryResetRequest_CALLBACK NULL | ||||
| #define PB_System_FactoryResetRequest_DEFAULT NULL | ||||
| 
 | ||||
| extern const pb_msgdesc_t PB_System_PingRequest_msg; | ||||
| extern const pb_msgdesc_t PB_System_PingResponse_msg; | ||||
| extern const pb_msgdesc_t PB_System_RebootRequest_msg; | ||||
| extern const pb_msgdesc_t PB_System_DeviceInfoRequest_msg; | ||||
| extern const pb_msgdesc_t PB_System_DeviceInfoResponse_msg; | ||||
| extern const pb_msgdesc_t PB_System_FactoryResetRequest_msg; | ||||
| 
 | ||||
| /* Defines for backwards compatibility with code written before nanopb-0.4.0 */ | ||||
| #define PB_System_PingRequest_fields &PB_System_PingRequest_msg | ||||
| @ -106,12 +118,14 @@ extern const pb_msgdesc_t PB_System_DeviceInfoResponse_msg; | ||||
| #define PB_System_RebootRequest_fields &PB_System_RebootRequest_msg | ||||
| #define PB_System_DeviceInfoRequest_fields &PB_System_DeviceInfoRequest_msg | ||||
| #define PB_System_DeviceInfoResponse_fields &PB_System_DeviceInfoResponse_msg | ||||
| #define PB_System_FactoryResetRequest_fields &PB_System_FactoryResetRequest_msg | ||||
| 
 | ||||
| /* Maximum encoded size of messages (where known) */ | ||||
| /* PB_System_PingRequest_size depends on runtime parameters */ | ||||
| /* PB_System_PingResponse_size depends on runtime parameters */ | ||||
| /* PB_System_DeviceInfoResponse_size depends on runtime parameters */ | ||||
| #define PB_System_DeviceInfoRequest_size         0 | ||||
| #define PB_System_FactoryResetRequest_size       0 | ||||
| #define PB_System_RebootRequest_size             2 | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
|  | ||||
| @ -1 +1 @@ | ||||
| Subproject commit 5761a23786b4729303bfa49142effea51870e549 | ||||
| Subproject commit f6fdc10e6d111b289188e88ac1d432698bb739cf | ||||
| @ -61,6 +61,14 @@ void furi_hal_rfid_pins_read() { | ||||
|     hal_gpio_init(&gpio_rfid_data_in, GpioModeAnalog, GpioPullNo, GpioSpeedLow); | ||||
| } | ||||
| 
 | ||||
| void furi_hal_rfid_pin_pull_release() { | ||||
|     hal_gpio_write(&gpio_rfid_pull, true); | ||||
| } | ||||
| 
 | ||||
| void furi_hal_rfid_pin_pull_pulldown() { | ||||
|     hal_gpio_write(&gpio_rfid_pull, false); | ||||
| } | ||||
| 
 | ||||
| void furi_hal_rfid_tim_read(float freq, float duty_cycle) { | ||||
|     // TODO LL init
 | ||||
|     uint32_t period = (uint32_t)((SystemCoreClock) / freq) - 1; | ||||
|  | ||||
| @ -66,6 +66,14 @@ void furi_hal_rfid_pins_read() { | ||||
|     hal_gpio_init(&gpio_rfid_data_in, GpioModeAnalog, GpioPullNo, GpioSpeedLow); | ||||
| } | ||||
| 
 | ||||
| void furi_hal_rfid_pin_pull_release() { | ||||
|     hal_gpio_write(&gpio_rfid_pull, true); | ||||
| } | ||||
| 
 | ||||
| void furi_hal_rfid_pin_pull_pulldown() { | ||||
|     hal_gpio_write(&gpio_rfid_pull, false); | ||||
| } | ||||
| 
 | ||||
| void furi_hal_rfid_tim_read(float freq, float duty_cycle) { | ||||
|     // TODO LL init
 | ||||
|     uint32_t period = (uint32_t)((SystemCoreClock) / freq) - 1; | ||||
|  | ||||
| @ -29,6 +29,14 @@ void furi_hal_rfid_pins_emulate(); | ||||
|  */ | ||||
| void furi_hal_rfid_pins_read(); | ||||
| 
 | ||||
| /** Release rfid pull pin
 | ||||
|  */ | ||||
| void furi_hal_rfid_pin_pull_release(); | ||||
| 
 | ||||
| /** Pulldown rfid pull pin
 | ||||
|  */ | ||||
| void furi_hal_rfid_pin_pull_pulldown(); | ||||
| 
 | ||||
| /** Config rfid timer to read state
 | ||||
|  * | ||||
|  * @param      freq        timer frequency | ||||
|  | ||||
| @ -26,7 +26,7 @@ SubGhzProtocolCameAtomo* subghz_protocol_came_atomo_alloc() { | ||||
|     instance->common.te_short = 600; | ||||
|     instance->common.te_long = 1200; | ||||
|     instance->common.te_delta = 250; | ||||
|     instance->common.type_protocol = SubGhzProtocolCommonTypeStatic; | ||||
|     instance->common.type_protocol = SubGhzProtocolCommonTypeDynamic; | ||||
|     instance->common.to_string = (SubGhzProtocolCommonToStr)subghz_protocol_came_atomo_to_str; | ||||
|     instance->common.to_load_protocol = | ||||
|         (SubGhzProtocolCommonLoadFromRAW)subghz_decoder_came_atomo_to_load_protocol; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Aleksandr Kutuzov
						Aleksandr Kutuzov