Naming and coding style convention, new linter tool. (#945)
* Makefile, Scripts: new linter * About: remove ID from IC * Firmware: remove double define for DIVC/DIVR * Scripts: check folder names too. Docker: replace syntax check with make lint. * Reformat Sources and Migrate to new file naming convention * Docker: symlink clang-format-12 to clang-format * Add coding style guide
This commit is contained in:
@@ -20,21 +20,20 @@ bool irda_decoder_rc6_interpret(IrdaCommonDecoder* decoder) {
|
||||
furi_assert(decoder);
|
||||
|
||||
bool result = false;
|
||||
uint32_t* data = (void*) &decoder->data[0];
|
||||
uint32_t* data = (void*)&decoder->data[0];
|
||||
// MSB first
|
||||
uint8_t address = reverse((uint8_t) (*data >> 5));
|
||||
uint8_t command = reverse((uint8_t) (*data >> 13));
|
||||
uint8_t address = reverse((uint8_t)(*data >> 5));
|
||||
uint8_t command = reverse((uint8_t)(*data >> 13));
|
||||
bool start_bit = *data & 0x01;
|
||||
bool toggle = !!(*data & 0x10);
|
||||
uint8_t mode = (*data >> 1) & 0x7;
|
||||
|
||||
if ((start_bit == 1) && (mode == 0)) {
|
||||
if((start_bit == 1) && (mode == 0)) {
|
||||
IrdaMessage* message = &decoder->message;
|
||||
IrdaRc6Decoder *rc6_decoder = decoder->context;
|
||||
bool *prev_toggle = &rc6_decoder->toggle;
|
||||
if ((message->address == address)
|
||||
&& (message->command == command)
|
||||
&& (message->protocol == IrdaProtocolRC6)) {
|
||||
IrdaRc6Decoder* rc6_decoder = decoder->context;
|
||||
bool* prev_toggle = &rc6_decoder->toggle;
|
||||
if((message->address == address) && (message->command == command) &&
|
||||
(message->protocol == IrdaProtocolRC6)) {
|
||||
message->repeat = (toggle == *prev_toggle);
|
||||
} else {
|
||||
message->repeat = false;
|
||||
@@ -55,31 +54,31 @@ bool irda_decoder_rc6_interpret(IrdaCommonDecoder* decoder) {
|
||||
* it separately and than pass decoding for other bits to
|
||||
* common manchester decode function.
|
||||
*/
|
||||
IrdaStatus irda_decoder_rc6_decode_manchester(IrdaCommonDecoder* decoder, bool level, uint32_t timing) {
|
||||
IrdaStatus
|
||||
irda_decoder_rc6_decode_manchester(IrdaCommonDecoder* decoder, bool level, uint32_t timing) {
|
||||
// 4th bit lasts 2x times more
|
||||
IrdaStatus status = IrdaStatusError;
|
||||
uint16_t bit = decoder->protocol->timings.bit1_mark;
|
||||
uint16_t tolerance = decoder->protocol->timings.bit_tolerance;
|
||||
|
||||
bool single_timing = MATCH_TIMING(timing, bit, tolerance);
|
||||
bool double_timing = MATCH_TIMING(timing, 2*bit, tolerance);
|
||||
bool triple_timing = MATCH_TIMING(timing, 3*bit, tolerance);
|
||||
bool double_timing = MATCH_TIMING(timing, 2 * bit, tolerance);
|
||||
bool triple_timing = MATCH_TIMING(timing, 3 * bit, tolerance);
|
||||
|
||||
if (decoder->databit_cnt == 4) {
|
||||
if(decoder->databit_cnt == 4) {
|
||||
furi_assert(decoder->switch_detect == true);
|
||||
|
||||
if (single_timing ^ triple_timing) {
|
||||
if(single_timing ^ triple_timing) {
|
||||
++decoder->databit_cnt;
|
||||
decoder->data[0] |= (single_timing ? !level : level) << 4;
|
||||
status = IrdaStatusOk;
|
||||
}
|
||||
} else if (decoder->databit_cnt == 5) {
|
||||
if (single_timing || triple_timing) {
|
||||
if (triple_timing)
|
||||
timing = bit;
|
||||
} else if(decoder->databit_cnt == 5) {
|
||||
if(single_timing || triple_timing) {
|
||||
if(triple_timing) timing = bit;
|
||||
decoder->switch_detect = false;
|
||||
status = irda_common_decode_manchester(decoder, level, timing);
|
||||
} else if (double_timing) {
|
||||
} else if(double_timing) {
|
||||
status = IrdaStatusOk;
|
||||
}
|
||||
} else {
|
||||
@@ -112,4 +111,3 @@ void irda_decoder_rc6_reset(void* decoder) {
|
||||
IrdaRc6Decoder* decoder_rc6 = decoder;
|
||||
irda_common_decoder_reset(decoder_rc6->common_decoder);
|
||||
}
|
||||
|
||||
|
@@ -17,9 +17,9 @@ void irda_encoder_rc6_reset(void* encoder_ptr, const IrdaMessage* message) {
|
||||
IrdaCommonEncoder* common_encoder = encoder->common_encoder;
|
||||
irda_common_encoder_reset(common_encoder);
|
||||
|
||||
uint32_t* data = (void*) common_encoder->data;
|
||||
*data |= 0x01; // start bit
|
||||
(void) *data; // 3 bits for mode == 0
|
||||
uint32_t* data = (void*)common_encoder->data;
|
||||
*data |= 0x01; // start bit
|
||||
(void)*data; // 3 bits for mode == 0
|
||||
*data |= encoder->toggle_bit ? 0x10 : 0;
|
||||
*data |= reverse(message->address) << 5;
|
||||
*data |= reverse(message->command) << 13;
|
||||
@@ -48,13 +48,14 @@ void irda_encoder_rc6_free(void* encoder_ptr) {
|
||||
free(encoder);
|
||||
}
|
||||
|
||||
IrdaStatus irda_encoder_rc6_encode_manchester(IrdaCommonEncoder* common_encoder, uint32_t* duration, bool* polarity) {
|
||||
IrdaStatus irda_encoder_rc6_encode_manchester(
|
||||
IrdaCommonEncoder* common_encoder,
|
||||
uint32_t* duration,
|
||||
bool* polarity) {
|
||||
IrdaStatus status = IrdaStatusError;
|
||||
|
||||
bool toggle_bit = (common_encoder->bits_encoded == 4);
|
||||
status = irda_common_encode_manchester(common_encoder, duration, polarity);
|
||||
if (toggle_bit)
|
||||
*duration *= 2;
|
||||
if(toggle_bit) *duration *= 2;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@@ -2,17 +2,16 @@
|
||||
#include "irda_protocol_defs_i.h"
|
||||
|
||||
static const IrdaProtocolSpecification irda_rc6_protocol_specification = {
|
||||
.name = "RC6",
|
||||
.address_length = 8,
|
||||
.command_length = 8,
|
||||
.frequency = IRDA_RC6_CARRIER_FREQUENCY,
|
||||
.duty_cycle = IRDA_RC6_DUTY_CYCLE,
|
||||
.name = "RC6",
|
||||
.address_length = 8,
|
||||
.command_length = 8,
|
||||
.frequency = IRDA_RC6_CARRIER_FREQUENCY,
|
||||
.duty_cycle = IRDA_RC6_DUTY_CYCLE,
|
||||
};
|
||||
|
||||
const IrdaProtocolSpecification* irda_rc6_get_spec(IrdaProtocol protocol) {
|
||||
if (protocol == IrdaProtocolRC6)
|
||||
if(protocol == IrdaProtocolRC6)
|
||||
return &irda_rc6_protocol_specification;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user