Author | Rob Jansen, Copyright © 2023..2023, all rights reserved. |
Adapted-by | |
Compiler | 2.5r8 |
Library for decoding Philps RC5 (extended) and RC6 mode 0 Remote Control messages. The library can be configured to use either the external interrupt (0) or an IOC interrupt to decode the Remote Control Messages. The default is using an external interupt (0). In order to switch to using an IOC interrupt the user must initialize the IOC to be active on both the rising and falling edge and must define the following alias (example for IOC on pin A2): alias philips_rc_decoder_ioc_flag is IOCAF_IOCAF2
Documentation on RC5 and RC6 mode 0 protocol. https://en.wikipedia.org/wiki/RC-5
The 36 kHz Infra Red receiver (active low) must be connected to the external interrupt pin or the used IOC pin.
No dependency found
const dword _PHILIPS_RC6_1T_MAX = (577 * PHILIPS_RC_SCALING) / 100
const byte _PHILIPS_RC_IDLE = 0
const dword _PHILIPS_RC5_2T_MAX = (2220 * PHILIPS_RC_SCALING) / 100
const dword _PHILIPS_RC5_2T_MIN = (1334 * PHILIPS_RC_SCALING) / 100
var word _philips_rc_bit_time
var byte _philips_rc_address
const byte PHILIPS_RC5_BITS = 13
const dword _PHILIPS_RC6_3T_MAX = (1731 * PHILIPS_RC_SCALING) / 100
const dword _PHILIPS_RC6_6T_MIN = (1864 * PHILIPS_RC_SCALING) / 100
const byte PHILIPS_RC6_BITS = 21
const byte _PHILIPS_RC5_DATA = 2
var bit _philips_rc5_available
var bit _philips_rc5_extended
const byte _PHILIPS_RC_PENDING = 5
const dword _PHILIPS_RC6_1T_MIN = (310 * PHILIPS_RC_SCALING) / 100
const dword _PHILIPS_RC6_2T_MIN = (621 * PHILIPS_RC_SCALING) / 100
const dword _PHILIPS_RC5_1T_MIN = (666 * PHILIPS_RC_SCALING) / 100
var bit _philips_edge
var byte _philips_rc_command
var bit _philips_rc_bit_half
var byte _philips_rc_count
const word _PHILIPS_RC_OVERFLOW = 65535
const dword _PHILIPS_RC6_3T_MIN = (932 * PHILIPS_RC_SCALING) / 100
var bit _philips_rc5_pending
const _PHILIPS_RC_EDGE_FALLING = FALSE
var bit _philips_rc_toggle
var byte _philips_rc_state
const byte _PHILIPS_RC6_DATA = 4
var dword _philips_rc_message
const byte _PHILIPS_RC_START = 1
const byte _PHILIPS_RC6_HEADER = 3
var bit _philips_rc_timer1_expired
const _PHILIPS_RC_EDGE_RISING = TRUE
const dword _PHILIPS_RC5_1T_MAX = (1110 * PHILIPS_RC_SCALING) / 100
var bit _philips_rc6_pending
const dword _PHILIPS_RC6_6T_MAX = (3463 * PHILIPS_RC_SCALING) / 100
var bit _philips_rc6_available
var byte _philips_rc_mode
const dword _PHILIPS_RC6_2T_MAX = (1154 * PHILIPS_RC_SCALING) / 100
_philips_rc_timer1_interrupt()
_philips_rc_interrupt()
_philips_rc_reset_decoder()
_philips_rc_timer1_preset(word in preset_value)
const dword _PHILIPS_RC6_1T_MAX = (577 * PHILIPS_RC_SCALING) / 100
No documentation found
const byte _PHILIPS_RC_IDLE = 0
Decoder states.
const dword _PHILIPS_RC5_2T_MAX = (2220 * PHILIPS_RC_SCALING) / 100
No documentation found
const dword _PHILIPS_RC5_2T_MIN = (1334 * PHILIPS_RC_SCALING) / 100
No documentation found
var word _philips_rc_bit_time
Layout of Philips Remote Control message for RC5: bit 15 .. 13 = 0 bit 12 = Field bit (1). '1' = RC5 standard,'0' = RC5 extended bit 11 = Toggle bit (1) bit 10 .. 6 = Address bits (5) or + 1 for RC5 extended bit 5 .. 0 = Command bits (6) Layout of Philips Remote Control message for RC6: bit 31 .. 21 = 0 bit 20 = Second start bit. Must be '1' bit 19 .. 17 = Mode bits (3) bit 16 = Toggle bit (1) bit 15 .. 8 = Address bits (8) bit 7 .. 0 = Command bits (8)
var byte _philips_rc_address
Holds the received address
const byte PHILIPS_RC5_BITS = 13
Number of bits in RC messages.
const dword _PHILIPS_RC6_3T_MAX = (1731 * PHILIPS_RC_SCALING) / 100
No documentation found
const dword _PHILIPS_RC6_6T_MIN = (1864 * PHILIPS_RC_SCALING) / 100
No documentation found
const byte PHILIPS_RC6_BITS = 21
Number of bits in RC6 message
const byte _PHILIPS_RC5_DATA = 2
No documentation found
var bit _philips_rc5_available
Indicates that an RC5 message is available
var bit _philips_rc5_extended
When set, it is an RC5 extended message.
const byte _PHILIPS_RC_PENDING = 5
No documentation found
const dword _PHILIPS_RC6_1T_MIN = (310 * PHILIPS_RC_SCALING) / 100
RC6 Contants. A half bit time is 444 us or 444 timer ticks. For minimum and maximum bit times we accept 25% tolerance to increase sensitivity.
const dword _PHILIPS_RC6_2T_MIN = (621 * PHILIPS_RC_SCALING) / 100
No documentation found
const dword _PHILIPS_RC5_1T_MIN = (666 * PHILIPS_RC_SCALING) / 100
RC5 Contants. A half bit time is 888 us or 888 timer ticks. For minimum and maximum bit times we accept 25% tolerance to increase sensitivity.
var bit _philips_edge
If set, the interrupt will trigger on a rising edge
var byte _philips_rc_command
Holds the received command
var bit _philips_rc_bit_half
Indicates that we are half way a bit
var byte _philips_rc_count
Received bits counter
const word _PHILIPS_RC_OVERFLOW = 65535
Max value of timer 1 before overflow.
const dword _PHILIPS_RC6_3T_MIN = (932 * PHILIPS_RC_SCALING) / 100
No documentation found
var bit _philips_rc5_pending
Indicates that an RC5 message is almost received
const _PHILIPS_RC_EDGE_FALLING = FALSE
No documentation found
var bit _philips_rc_toggle
Holds the received RC5 toggle bit
var byte _philips_rc_state
Decoder state machine variable
const byte _PHILIPS_RC6_DATA = 4
No documentation found
var dword _philips_rc_message
Internal decoding variables.
const byte _PHILIPS_RC_START = 1
No documentation found
const byte _PHILIPS_RC6_HEADER = 3
No documentation found
var bit _philips_rc_timer1_expired
If set, timer has overflown
const _PHILIPS_RC_EDGE_RISING = TRUE
We decode the IR bitstream on both edges for better performance.
const dword _PHILIPS_RC5_1T_MAX = (1110 * PHILIPS_RC_SCALING) / 100
No documentation found
var bit _philips_rc6_pending
Indicates that an RC6 message is almost received
const dword _PHILIPS_RC6_6T_MAX = (3463 * PHILIPS_RC_SCALING) / 100
No documentation found
var bit _philips_rc6_available
Indicates that an RC6 message is available
var byte _philips_rc_mode
Holds the received mode (RC6 only)
const dword _PHILIPS_RC6_2T_MAX = (1154 * PHILIPS_RC_SCALING) / 100
No documentation found
philips_rc_get_data(bit out toggle, byte out address, byte out command)
Return the last received RC5 or RC6 data. After called, the message received flags are cleared.
philips_rc_decoder_init()
Initialize the Philps RC5/RC6 Remote Control Decoder. This will initialize the required interrupts.
_philips_rc_timer1_interrupt()
Timer1 interrupt. Occurs when the timer overflows.
_philips_rc_interrupt()
External interrupt.
_philips_rc_reset_decoder()
Reset the Remote Control decoder to its initial state.
_philips_rc_timer1_preset(word in preset_value)
Preset Timer 1 and start the timer.
philips_rc6_message_received() return bit
Returns TRUE is a valid RC6 mode 0 Remote Control message was received.
philips_rc5_message_received() return bit
Returns TRUE is a valid RC5 Remote Control message was received.
_philips_rc_handle_interrupt_flag() return bit
This procedure handles the interupt flag. Reason for this procedure is to be able to use two differnt interrupt types, IOC and external.
_philips_rc_get_timer1_value() return word
Return the value of Timer 1. We return the Timer value if it has not overflown otherwise this function returns the overflow value.
16f1825 | 16f1825_philips_rc_decoder_serial.jal |
16f1825 | 16f1825_philips_rc_decoder_ssd1306.jal |
16f18857 | 16f18857_philips_rc_decoder_serial.jal |
16f877a | 16f877a_philips_rc_decoder_serial.jal |