📄 main.c
字号:
// *******************************************
// *******************************************
#include <stdio.h>
#include <string.h>
#include "i2c_intf.h"
#include "uart_int.h"
#include "mcu.h"
#include "timer.h"
#include "DP_RX_DRV.h"
#include "DP_RX_API.h"
#define DEF_DEBUG_MODE 0
char argc;
char *argv[3];
bit debug_mode;
bit enable_information;
bit port_sel;
void decode_term_str(void);
int hex_to_int(char *s);
void proc_term_cmd();
extern uchar CommandProcess ();
uchar debug_comm_tx();
void serial_isr(void) interrupt 4
{
UART_ISR(); _NOP_;
}
void timer1_isr(void) interrupt 1
{
timer_isr(); _NOP_;
}
uchar debug_comm_init()
{
DP_RX_WriteI2C_RX0(0,0xff);
DP_RX_WriteI2C_RX0(1,0xff);
DP_RX_WriteI2C_RX0(2,0xff);
DP_RX_WriteI2C_RX0(3,0xff);
DP_RX_WriteI2C_RX0(4,0xff);
DP_RX_WriteI2C_RX0(5,0xff);
}
uchar debug_comm_tx()
{
command_buf[0]=0x2a;
command_buf[1]=0x52;
command_buf[2]=0x50;
command_buf[3]=0x00;
command_buf[4]=0x08;
command_buf[5]=0x0d;
sendRQ=1;
}
void main ()
{
uchar temp[16]="DPRX_BOCOM_V1_0";
enable_debug_output = 1; // 1 enable debug information
debug_mode = DEF_DEBUG_MODE; // 1 debug on , 0 debug off
enable_information = 1;
InitMCU ();
SendToPCSomeByte(temp,15,1);
// debug_printf("DP_RX MCU FirmWare version: %.2f \n",DP_Rx_FW_VER);
DP_RX_API_Chip_Located();
DP_RX_API_InitSys();
//debug_comm_init();
while(0)
{
LED = 0;
delay_ms(500);
LED = 1;
delay_ms(500);
}
//set 2 lane, bandwidth 2.7G, single LVDS output, 8Bit output
DP_RX_API_Set_LaneCount(2);
B_puts("2 lanes selected");
DP_RX_API_Set_BandWidth(0x0a);
B_puts("2.7G selected");
DP_RX_API_Set_LVDS_Dual_Single(SINGLE_LVDS);
B_puts("Single LVDS selected");
DP_RX_API_Set_LVDS_Format(VESA_8bit);
B_puts("VESA 8 bit selected");
DP_RX_API_LVDS_Output_Mapping(5, 0);
DP_RX_API_LVDS_Output_Mapping(4, 1);
DP_RX_API_LVDS_Output_Mapping(3, 3);
DP_RX_API_LVDS_Output_Mapping(2, 2);
DP_RX_API_LVDS_Output_Mapping(1, 4);
DP_RX_API_LVDS_Output_Mapping(0, 5);
B_puts("Single LVDS output mapping");
// test = 'a';
while (1)
{
if(!debug_mode)
DP_RX_API_MainTask();
// debug_comm_tx();
CommandProcess ();
//
// BP_DIR = 1;
// putchar(test);
// BP_DIR = 0;
//lllll,
LED=~LED;
#if !Disable_interrupt
EX1 = 1;
#endif
delay_ms(3000);
}
}
void decode_term_str(void)
{
char *s, *s1;
char space;
s = command_buf;
s1 = s;
argc = 0;
if (*s) {
space = 0;
argv[argc++] = s;
while (*s) {
if (*s == ' ') {
*s = 0;
if (!space) {
space = 1;
}
} else {
if (space)
argv[argc++] = s;
space = 0;
}
s++;
}
}
}
int hex_to_int(char *s)
{
int r;
r = 0;
while (*s) {
if (*s >= '0' && *s <= '9')
r = (r << 4) + *s - '0';
if (*s >= 'a' && *s <= 'f')
r = (r << 4) + *s - 'a' + 10;
if (*s >= 'A' && *s <= 'F')
r = (r << 4) + *s - 'A' + 10;
s++;
}
return r;
}
uchar CommandProcess()
{
uchar temp;
uchar i;
uchar sendbuf[20];
if (sendRQ)
{
sendRQ=0;
if(command_buf[1]==0x52)
{
for(i=0;i<20;i++)
{
sendbuf[i] =0x0d;
}
for(i=0;i<5;i++)
{
sendbuf[i] = command_buf[i];
}
if(command_buf[2]==0x50)
{
for(i=0;i<command_buf[4];i++)
{
DP_RX_ReadI2C_RX0(command_buf[3]+i,&sendbuf[i+5]);
}
}
else if(command_buf[2]==0x8c)
{
for(i=0;i<command_buf[4];i++)
{
DP_RX_ReadI2C_RX1(command_buf[3]+i,&sendbuf[i+5]);
}
}
else
{
return 0;
}
SendToPCSomeByte(sendbuf,command_buf[4]+6,0); //不需要回车
}
else if(command_buf[1]==0x57)
{
if(command_buf[2]==0x50)
{
DP_RX_WriteI2C_RX0(command_buf[3],command_buf[4]);
}
else if(command_buf[2]==0x8c)
{
DP_RX_WriteI2C_RX1(command_buf[3],command_buf[4]);
}
}
}
}
/* process terminal command */
/*
void proc_term_cmd()
{
unsigned char c, c1;
unsigned char i;
if (argc == 0)
return;
if ((!strcmp(argv[0], "rp0") == 1) ||(!strcmp(argv[0], "RP0") == 1)) {
c = DP_RX_ReadI2C_RX0(hex_to_int(argv[1]), &c1);
debug_printf("rp0: %.2x, [%s]=%.2x\n", (unsigned int)c, argv[1], (unsigned int)c1);
}
else if(!strcmp(argv[0],"show") )
DP_RX_Show_Vid_Info();
else if ((!strcmp(argv[0], "rp1") == 1) ||(!strcmp(argv[0], "RP1") == 1)) {
c = DP_RX_ReadI2C_RX1(hex_to_int(argv[1]), &c1);
debug_printf("rp1: %.2x, [%s]=%.2x\n", (unsigned int)c, argv[1], (unsigned int)c1);
}
else if ((!strcmp(argv[0], "wp0") == 1) ||(!strcmp(argv[0], "WP0") == 1)) {
c = DP_RX_WriteI2C_RX0(hex_to_int(argv[1]), hex_to_int(argv[2]));
debug_printf("wp0: %.2x, [%s]=%s\n", (unsigned int)c, argv[1], argv[2]);
}
else if ((!strcmp(argv[0], "wp1") == 1) ||(!strcmp(argv[0], "WP1") == 1)) {
c = DP_RX_WriteI2C_RX1(hex_to_int(argv[1]), hex_to_int(argv[2]));
debug_printf("wp1: %.2x, [%s]=%s\n", (unsigned int)c, argv[1], argv[2]);
}
else if ((!strcmp(argv[0], "HPD")==1)||(!strcmp(argv[0], "hpd")==1)) {
DP_RX_HPD(0);
delay_ms(hex_to_int(argv[1]));
DP_RX_HPD(1);
}
else if ((!strcmp(argv[0], "IRQ")==1)||(!strcmp(argv[0], "irq")==1)) {
DP_RX_HPD(0);
delay_half_ms();
DP_RX_HPD(1);
}
else if (!strcmp(argv[0],"rp0all") ){
debug_printf(" 0 1 2 3 4 5 6 7 8 9 A B C D E F");
for(i=0;i<128;i++)
{
DP_RX_ReadI2C_RX0(i,&c1);
if((i&0x0f)==0)
debug_printf("\n rp0: [%.2x] %.2x ", (unsigned int)i, (unsigned int)c1);
else
debug_printf("%.2x ", (unsigned int)c1);
if((i&0x0f)==0x0f)
debug_printf("\n-------------------------------------");
}
for(i=0;i<128;i++)
{
DP_RX_ReadI2C_RX0(i+128,&c1);
if((i&0x0f)==0)
debug_printf("\n rp0: [%.2x] %.2x ", (unsigned int)(i+128), (unsigned int)c1);
else
debug_printf("%.2x ", (unsigned int)c1);
if((i&0x0f)==0x0f)
debug_printf("\n-------------------------------------");
}
debug_printf("\n");
}
else if (!strcmp(argv[0], "rp1all"))
{
debug_printf(" 0 1 2 3 4 5 6 7 8 9 A B C D E F");
for(i=0;i<128;i++)
{
DP_RX_ReadI2C_RX1(i,&c1);
if((i&0x0f)==0)
debug_printf("\n rp1: [%.2x] %.2x ", (unsigned int)i, (unsigned int)c1);
else
debug_printf("%.2x ", (unsigned int)c1);
if((i&0x0f)==0x0f)
debug_printf("\n-------------------------------------");
}
for(i=0;i<128;i++)
{
DP_RX_ReadI2C_RX1(i+128,&c1);
if((i&0x0f)==0)
debug_printf("\n rp1: [%.2x] %.2x ", (unsigned int)(i+128), (unsigned int)c1);
else
debug_printf("%.2x ", (unsigned int)c1);
if((i&0x0f)==0x0f)
debug_printf("\n-------------------------------------");
}
debug_printf("\n");
}
else if(!strcmp(argv[0], "debugon"))
debug_mode = 1;
else if(!strcmp(argv[0], "debugoff"))
debug_mode = 0;
else
debug_printf("unknown command: %s\n", argv[0]);
}
void CommandProcess ()
{
if (cmd_valid)
{
cmd_valid = 0;
process_cmd();
}
if (term_cmd_valid)
{
term_cmd_valid = 0;
command_buf[command_buf_len] = 0;
enable_debug_output = 1;
decode_term_str();
proc_term_cmd();
enable_debug_output = enable_information;
}
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -