repo_id
stringclasses
1 value
file_path
stringlengths
49
87
content
stringlengths
25
158
__index_level_0__
int64
0
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Master.c
<comment>启用IIC接口<code>SIMCR = C_IIC_En;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Master.c
<comment>启用IIC接口并设置主模式<code>SIMCR = (C_IIC_En | C_Master_En);
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Master.c
<comment>将数据0xA0加载到串行接口模式数据寄存器<code>SIMDR = 0xA0;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Master.c
<comment>等待传输数据<code>F_Wait_Loop();
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Master.c
<comment>启用IIC接口<code>SIMCR = C_IIC_En;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Master.c
<comment>启用IIC接口并设置主模式<code>SIMCR = (C_IIC_En | C_Master_En);
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Master.c
<comment>将数据0xA1加载到串行接口模式数据寄存器<code>SIMDR = 0xA1;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Master.c
<comment>等待传输数据<code>F_Wait_Loop();
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Master.c
<comment>选择RX模式<code>MCR = C_IIC_RX;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Master.c
<comment>等待传输数据<code>F_Wait_Loop();
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Master.c
<comment>TX -> RX,必须读取无效数据<code>R_Temp0 = SIMDR;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Master.c
<comment>主模式切换到从模式以生成停止信号<code>SIMCR = C_IIC_En;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Master.c
<comment>清除MIF标志<code>MSR = (unsigned char)~(C_MIF);
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Master.c
<comment>清除看门狗定时器<code>CLRWDT();
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>用于存储IIC数据<code>unsigned char R_IIC_Data;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>用于存储ACK/NACK标志<code>unsigned char R_ACK;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>临时变量<code>unsigned char R_Temp0;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>清除看门狗定时器<code>CLRWDT();
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>轮询MCF标志<code>while (!(MSR & 0x80));
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>等待主设备发送地址<code>F_Wait_Loop();
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>检查主设备是否调用地址<code>if (MSR & 0X40)
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>如果地址当前匹配,PB0=1<code>PORTBbits.PB0 = 1;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>清除PB0<code>PORTBbits.PB0 = 0;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>检查主设备命令<code>if (!(MSR & 0x04))
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>将接收到的数据发送到PORTA<code>PORTA = SIMDR;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>清除MIF标志<code>MSR = (unsigned char)~(C_MIF);
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>检查主设备命令<code>else if (MSR & 0x04)
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>确认是否进入TX状态,R_Temp2=1用于检查前一个数据的ACK/NAK,第一个数据跳过检查<code>if (R_ACK == 0x00)
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>选择TX模式<code>MCR = C_IIC_TX;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>发送数据<code>SIMDR = R_IIC_Data;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>数据递增<code>R_IIC_Data++;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>设置ACK标志<code>R_ACK = 0x01;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>检查TXAK,如果是ACK则传输下一个数据,NAK将停止传输<code>if (MSR & 0x01)
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>停止传输,必须设置RX模式并读取无效数据以释放SCL信号<code>MCR = 0x00;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>读取无效数据<code>R_Temp0 = SIMDR;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>重置数据<code>R_IIC_Data = 0x00;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>重置ACK标志<code>R_ACK = 0x00;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>清除MIF标志<code>MSR = (unsigned char)~(C_MIF);
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>选择TX模式<code>MCR = C_IIC_TX;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>发送数据<code>SIMDR = R_IIC_Data;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>数据递增<code>R_IIC_Data++;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>设置ACK标志<code>R_ACK = 0x01;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>设置所有PORTC为输出模式<code>IOSTC = C_PC_Output;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>设置所有PORTB为输出模式<code>IOSTB = C_PB_Output;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>设置所有PORTA为输出模式<code>IOSTA = C_PA_Output;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>PORTC数据缓冲区=0x00(PC1~PC0输出低电平)<code>PORTC = (unsigned char)~(C_PC_Data);
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>PORTB数据缓冲区=0x00(PB7~PB0输出低电平)<code>PORTB = (unsigned char)~(C_PB_Data);
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>PORTA数据缓冲区=0x00(PA7~PA0输出低电平)<code>PORTA = (unsigned char)~(C_PA_Data);
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>启用IIC接口<code>SIMCR = C_IIC_En;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>清除MIF标志<code>MSR = (unsigned char)~(C_MIF);
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>选择RX模式并发送ACK<code>MCR = C_IIC_RX | C_ACK;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>IIC模式频率 = CPU时钟/22<code>MFDR = C_FD_Div22;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>设置从地址b'0010101x,x=0写,x=1读<code>MADR = 0x2A;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>初始化串行接口模式数据寄存器<code>SIMDR = 0x00;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>初始化IIC数据<code>R_IIC_Data = 0x00;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>清除看门狗定时器<code>CLRWDT();
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\IIC_Slave.c
<comment>检查主设备命令<code>F_Check_Master_CMD();
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\LVD.c
<comment>包含NY8A051F微控制器的头文件<code>#include <ny8.h>
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\LVD.c
<comment>包含NY8A051F的宏定义<code>#include "NY8_constant.h"
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\LVD.c
<comment>设置所有PB端口输出低电平<code>PORTB = 0x00;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\LVD.c
<comment>配置PB端口为输出模式<code>IOSTB = C_PB_Output;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\LVD.c
<comment>禁用所有未屏蔽的中断<code>DISI();
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\LVD.c
<comment>禁用中断使能寄存器<code>INTE = 0x00;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\LVD.c
<comment>设置时钟倍频器和分频器(使用I_HRC的4MHz/4T)<code>CMPCR = 0x0A;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\LVD.c
<comment>启用LVD<code>PCONbits.LVDEN = 1;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\LVD.c
<comment>设置LVD阈值为3.0V(LVDS[3:0] = 0101b)<code>PCON1 = C_LVD_3P0V;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\LVD.c
<comment>无限循环,持续检查LVD状态<code>while(1)
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\LVD.c
<comment>检查LVDOUT是否被设置(VDD低于LVD阈值)<code>if(PCON1 & 0x40)
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\LVD.c
<comment>设置PB0为高电平,表示LVD事件<code>PORTBbits.PB0 = 1;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\LVD.c
<comment>如果VDD高于LVD阈值,设置PB0为低电平<code>PORTBbits.PB0 = 0;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\LVD.c
<comment>清除看门狗定时器,防止WDT超时复位<code>CLRWDT();
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>包含NY8A051F微控制器的头文件<code>#include <ny8.h>
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>包含NY8A051F的宏定义<code>#include "ny8_constant.h"
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>用于临时存储OSCCAL值<code>unsigned int R_OSCCAL_TEMP;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>用于保存OSCCALH的默认值<code>unsigned char R_OSCCALH_SAVE;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>用于保存OSCCALL的默认值<code>unsigned char R_OSCCALL_SAVE;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>用于指示增加或减少的方向<code>unsigned char R_Direction;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>定义宏a<code>#define a 0
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>定义宏r<code>#define r 1
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>定义PWM占空比为50%的值<code>#define PWM_DUTY_0x02 0x02
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>加载到OSCCAL的子程序声明<code>void F_LoadtoOSCCAL(void);
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>恢复到OSCCAL的子程序声明<code>void F_RestoretoOSCCAL(void);
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>延时子程序声明<code>void delay(int);
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>中断服务例程<code>void isr(void) __interrupt(0)
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>使能PB0~5的上拉电阻<code>BPHCON = ~C_PB_PHB;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>使能PA0~4,PA6~7的上拉电阻<code>APHCON = C_PA5_PLB;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>清除PORTC数据<code>PORTC = 0;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>清除PORTB数据<code>PORTB = 0;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>清除PORTA数据<code>PORTA = 0;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>设置PORTC为输出<code>IOSTC = C_PC_Output;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>设置PORTB为输入<code>IOSTB = C_PB_Input;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>保存OSCCALH的默认值<code>R_OSCCALH_SAVE = OSCCALH & 0x07;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>保存OSCCALL的默认值<code>R_OSCCALL_SAVE = OSCCALL;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>保存[OSCCALH:OSCCALL]到R_OSCCALH_TEMP<code>R_OSCCAL_TEMP = R_OSCCALL_SAVE | (R_OSCCALH_SAVE << 8);
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>设置TM4RH为0<code>TM4RH = 0;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>设置TMR4为0x03<code>TMR4 = 0x03;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>关闭Prescaler4<code>T4CR2 = C_PS4_Dis;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>设置PWM4占空比为50%<code>PWM4DUTY = PWM_DUTY_0x02;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>PWM4输出在PA4,启用特殊高频振荡器作为Timer4时钟源,启用Timer4<code>T4CR1 = C_PWM4_En | C_TMR4_IHRC_En | C_TMR4_Reload | C_TMR4_En | C_VFSEL4;
0
C:\Users\IDEA\Desktop\workplace\LiuCode
C:\Users\IDEA\Desktop\workplace\LiuCode\Liu\OSCALL.c
<comment>主循环<code>while(1)
0