[FL-2279] IR doxygen, rename irda -> infrared (#1010)
* IR: Doxygen docs, some rename * Rename irda -> infrared * Rollback collateral renames Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
		
							
								
								
									
										60
									
								
								lib/infrared/encoder_decoder/sirc/infrared_decoder_sirc.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								lib/infrared/encoder_decoder/sirc/infrared_decoder_sirc.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,60 @@ | ||||
| #include "common/infrared_common_i.h" | ||||
| #include "infrared.h" | ||||
| #include "infrared_protocol_defs_i.h" | ||||
| #include <stdbool.h> | ||||
| #include <stdint.h> | ||||
| #include <furi.h> | ||||
| #include "../infrared_i.h" | ||||
|  | ||||
| InfraredMessage* infrared_decoder_sirc_check_ready(void* ctx) { | ||||
|     return infrared_common_decoder_check_ready(ctx); | ||||
| } | ||||
|  | ||||
| bool infrared_decoder_sirc_interpret(InfraredCommonDecoder* decoder) { | ||||
|     furi_assert(decoder); | ||||
|  | ||||
|     uint32_t* data = (void*)&decoder->data[0]; | ||||
|     uint16_t address = 0; | ||||
|     uint8_t command = 0; | ||||
|     InfraredProtocol protocol = InfraredProtocolUnknown; | ||||
|  | ||||
|     if(decoder->databit_cnt == 12) { | ||||
|         address = (*data >> 7) & 0x1F; | ||||
|         command = *data & 0x7F; | ||||
|         protocol = InfraredProtocolSIRC; | ||||
|     } else if(decoder->databit_cnt == 15) { | ||||
|         address = (*data >> 7) & 0xFF; | ||||
|         command = *data & 0x7F; | ||||
|         protocol = InfraredProtocolSIRC15; | ||||
|     } else if(decoder->databit_cnt == 20) { | ||||
|         address = (*data >> 7) & 0x1FFF; | ||||
|         command = *data & 0x7F; | ||||
|         protocol = InfraredProtocolSIRC20; | ||||
|     } else { | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
|     decoder->message.protocol = protocol; | ||||
|     decoder->message.address = address; | ||||
|     decoder->message.command = command; | ||||
|     /* SIRC doesn't specify repeat detection */ | ||||
|     decoder->message.repeat = false; | ||||
|  | ||||
|     return true; | ||||
| } | ||||
|  | ||||
| void* infrared_decoder_sirc_alloc(void) { | ||||
|     return infrared_common_decoder_alloc(&protocol_sirc); | ||||
| } | ||||
|  | ||||
| InfraredMessage* infrared_decoder_sirc_decode(void* decoder, bool level, uint32_t duration) { | ||||
|     return infrared_common_decode(decoder, level, duration); | ||||
| } | ||||
|  | ||||
| void infrared_decoder_sirc_free(void* decoder) { | ||||
|     infrared_common_decoder_free(decoder); | ||||
| } | ||||
|  | ||||
| void infrared_decoder_sirc_reset(void* decoder) { | ||||
|     infrared_common_decoder_reset(decoder); | ||||
| } | ||||
							
								
								
									
										73
									
								
								lib/infrared/encoder_decoder/sirc/infrared_encoder_sirc.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								lib/infrared/encoder_decoder/sirc/infrared_encoder_sirc.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | ||||
| #include "furi/check.h" | ||||
| #include "infrared.h" | ||||
| #include "common/infrared_common_i.h" | ||||
| #include <stdint.h> | ||||
| #include "../infrared_i.h" | ||||
| #include "infrared_protocol_defs_i.h" | ||||
| #include <furi.h> | ||||
|  | ||||
| void infrared_encoder_sirc_reset(void* encoder_ptr, const InfraredMessage* message) { | ||||
|     furi_assert(encoder_ptr); | ||||
|     furi_assert(message); | ||||
|  | ||||
|     InfraredCommonEncoder* encoder = encoder_ptr; | ||||
|     infrared_common_encoder_reset(encoder); | ||||
|  | ||||
|     uint32_t* data = (void*)encoder->data; | ||||
|  | ||||
|     if(message->protocol == InfraredProtocolSIRC) { | ||||
|         *data = (message->command & 0x7F); | ||||
|         *data |= (message->address & 0x1F) << 7; | ||||
|         encoder->bits_to_encode = 12; | ||||
|     } else if(message->protocol == InfraredProtocolSIRC15) { | ||||
|         *data = (message->command & 0x7F); | ||||
|         *data |= (message->address & 0xFF) << 7; | ||||
|         encoder->bits_to_encode = 15; | ||||
|     } else if(message->protocol == InfraredProtocolSIRC20) { | ||||
|         *data = (message->command & 0x7F); | ||||
|         *data |= (message->address & 0x1FFF) << 7; | ||||
|         encoder->bits_to_encode = 20; | ||||
|     } else { | ||||
|         furi_assert(0); | ||||
|     } | ||||
| } | ||||
|  | ||||
| InfraredStatus infrared_encoder_sirc_encode_repeat( | ||||
|     InfraredCommonEncoder* encoder, | ||||
|     uint32_t* duration, | ||||
|     bool* level) { | ||||
|     furi_assert(encoder); | ||||
|  | ||||
|     furi_assert(encoder->timings_encoded == (1 + 2 + encoder->bits_to_encode * 2 - 1)); | ||||
|  | ||||
|     furi_assert(encoder->timings_sum < INFRARED_SIRC_REPEAT_PERIOD); | ||||
|     *duration = INFRARED_SIRC_REPEAT_PERIOD - encoder->timings_sum; | ||||
|     *level = false; | ||||
|  | ||||
|     encoder->timings_sum = 0; | ||||
|     encoder->timings_encoded = 1; | ||||
|     encoder->bits_encoded = 0; | ||||
|     encoder->state = InfraredCommonEncoderStatePreamble; | ||||
|  | ||||
|     return InfraredStatusOk; | ||||
| } | ||||
|  | ||||
| void* infrared_encoder_sirc_alloc(void) { | ||||
|     return infrared_common_encoder_alloc(&protocol_sirc); | ||||
| } | ||||
|  | ||||
| void infrared_encoder_sirc_free(void* encoder_ptr) { | ||||
|     infrared_common_encoder_free(encoder_ptr); | ||||
| } | ||||
|  | ||||
| InfraredStatus infrared_encoder_sirc_encode(void* encoder_ptr, uint32_t* duration, bool* level) { | ||||
|     InfraredCommonEncoder* encoder = encoder_ptr; | ||||
|  | ||||
|     InfraredStatus status = infrared_common_encode(encoder, duration, level); | ||||
|     if((status == InfraredStatusOk) && (encoder->bits_encoded == encoder->bits_to_encode)) { | ||||
|         furi_assert(!*level); | ||||
|         status = InfraredStatusDone; | ||||
|         encoder->state = InfraredCommonEncoderStateEncodeRepeat; | ||||
|     } | ||||
|     return status; | ||||
| } | ||||
							
								
								
									
										37
									
								
								lib/infrared/encoder_decoder/sirc/infrared_sirc_spec.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								lib/infrared/encoder_decoder/sirc/infrared_sirc_spec.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| #include "../infrared_i.h" | ||||
| #include "infrared_protocol_defs_i.h" | ||||
|  | ||||
| static const InfraredProtocolSpecification infrared_sirc_protocol_specification = { | ||||
|     .name = "SIRC", | ||||
|     .address_length = 5, | ||||
|     .command_length = 7, | ||||
|     .frequency = INFRARED_SIRC_CARRIER_FREQUENCY, | ||||
|     .duty_cycle = INFRARED_SIRC_DUTY_CYCLE, | ||||
| }; | ||||
|  | ||||
| static const InfraredProtocolSpecification infrared_sirc15_protocol_specification = { | ||||
|     .name = "SIRC15", | ||||
|     .address_length = 8, | ||||
|     .command_length = 7, | ||||
|     .frequency = INFRARED_SIRC_CARRIER_FREQUENCY, | ||||
|     .duty_cycle = INFRARED_SIRC_DUTY_CYCLE, | ||||
| }; | ||||
|  | ||||
| static const InfraredProtocolSpecification infrared_sirc20_protocol_specification = { | ||||
|     .name = "SIRC20", | ||||
|     .address_length = 13, | ||||
|     .command_length = 7, | ||||
|     .frequency = INFRARED_SIRC_CARRIER_FREQUENCY, | ||||
|     .duty_cycle = INFRARED_SIRC_DUTY_CYCLE, | ||||
| }; | ||||
|  | ||||
| const InfraredProtocolSpecification* infrared_sirc_get_spec(InfraredProtocol protocol) { | ||||
|     if(protocol == InfraredProtocolSIRC) | ||||
|         return &infrared_sirc_protocol_specification; | ||||
|     else if(protocol == InfraredProtocolSIRC15) | ||||
|         return &infrared_sirc15_protocol_specification; | ||||
|     else if(protocol == InfraredProtocolSIRC20) | ||||
|         return &infrared_sirc20_protocol_specification; | ||||
|     else | ||||
|         return NULL; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user