芯片解密C8051F350单片机红外语音系统源程序
芯片解密单片机源程序如下:
- #include "include.h"
- #include "sw_uart.h"
- #include "hw_uart.h"
- #include "timer2.h"
- #include "api.h"
- pt pt_comm;
- void init_gpio()
- {
- // P0.0 - Skipped, Open-Drain, Digital
- // P0.1 - Skipped, Open-Drain, Digital
- // P0.2 - Skipped, Open-Drain, Digital
- // P0.3 - Skipped, Open-Drain, Digital
- // P0.4 - TX0 (UART0), Push-Pull, Digital
- // P0.5 - RX0 (UART0), Open-Drain, Digital
- // P0.6 - Skipped, Open-Drain, Digital
- // P0.7 - Skipped, Open-Drain, Digital
- // P1.0 - Skipped, Open-Drain, Digital
- // P1.1 - CEX0 (PCA), Open-Drain, Digital
- // P1.2 - Unassigned, Open-Drain, Digital
- // P1.3 - Unassigned, Open-Drain, Digital
- // P1.4 - Unassigned, Open-Drain, Digital
- // P1.5 - Unassigned, Open-Drain, Digital
- // P1.6 - Unassigned, Push-Pull, Digital
- // P1.7 - Unassigned, Push-Pull, Digital
- // P2.0 - Unassigned, Open-Drain, Digital
- // P2.1 - Unassigned, Open-Drain, Digital
- // P2.2 - Unassigned, Open-Drain, Digital
- // P2.3 - Unassigned, Open-Drain, Digital
- P0MDOUT = 0x10;
- P1MDOUT = 0xC0;
- P0SKIP = 0xCF;
- P1SKIP = 0x01;
- XBR0 = 0x01;
- XBR1 = 0x41;
- }
- void init_sysclock()
- {
- OSCICN = 0x83;
- }
- void init_wtd(void)
- {
- // PCA0MD &= ~0x40; // 向WDTE写‘0’,禁止WDT
- // PCA0MD = 0x00; // PCA时钟源选择系统时钟的12分频
- // PCA0CPL2 = 0xFF; // 装入WDT更新偏移值为64.2ms
- // PCA0MD |= 0x40; // 向WDTE写‘1’,使能WDT
- // Calculate Watchdog Timer Timeout
- // Offset calculated in PCA clocks
- // Offset = ( 256 x PCA0CPL4 ) + 256 - PCA0L
- // = ( 256 x 255(0xFF)) + 256 - 0
- // Time = Offset * (12/SYSCLK)
- // = 255 ms ( PCA uses SYSCLK/12 as its clock source)
- PCA0MD &= 0xBF; // WDTE = 0 (clear watchdog timer enable)
- // PCA0L = 0x00; // Set lower byte of PCA counter to 0
- // PCA0H = 0x00; // Set higher byte of PCA counter to 0
- PCA0CPL4 = 0xFF; // Write offset for the WDT
- PCA0MD |= 0x40; // Enable the WDT
- }
- void feed_wtd(void)
- {
- //CCF2 = 0x00; // Write a 'dummy' value to the PCA0CPH4
- // register to reset the watchdog timer
- // timeout. If a delay longer than the
- // watchdog timer delay occurs between
- // successive writes to this register,
- // the device will be reset by the watch
- // dog timer.
- PCA0CPH4 =0x00;
- }
- unsigned char get_lamp_status(void)
- {
- if(PIN_RED_LAMP==0) return 1;
- else return 0;
- }

芯片解密