for(i=0;ov_reg[i].need != 0xff;i++)
{
if(ov_reg[i].need == 1)
{
temp = TWI_poll( TWI_CHIP_OV7660|TWI_WRITE, (ov_reg[i].addr), &(ov_reg[i].data) );
if( temp )
{
return temp;
}
}
}
txnum=0;
for(i=0;ov_reg[i].need != 0xff;i++)
{
if(ov_reg[i].need == 1)
{
temp = TWI_poll( TWI_CHIP_OV7660|TWI_READ, (ov_reg[i].addr), &(txPacket[txnum++]) );
if( temp )
{
return temp;
}
}
}
// uartDebug_txPacket(txPacket,txnum);
my_delay_ms(200);
return 0x00; //ok
}
/* OV7660_init() */
附录八、NRF24LE1芯片main.c部分
Main.c 文件:
#include <Nordic\reg24le1.h>
#include "hal_nrf_reg.h"
#include "hal_nrf.h"
#include "radio.h"
#include "application.h"
uint8_t xdata packet[RADIO_MAX_PL]; // Buffer for sending or receiving
char combuf[240];
char *p=&combuf[240];
void send_packet(uint8_t command)
{
bool packet_sent;
uint8_t data_length;
packet[0] = CMD_SEND_DATA; // Add TYPE (data = 0x00)
packet[1] = data_length = 1; // Add LENGTH (1 byte)
packet[DATA_POS] = command; // Add DATA to send
radio_send_packet(packet, data_length+DATA_POS);
while(radio_busy())
;
packet_sent = radio_packet_sent();
if(packet_sent)
{
// LED1_BLINK(); // Packet sent, flash LED1
}
else
{
// LED0_BLINK(); // Packet lost, flash LED0
}
}
uint8_t read_packet(void)
{
uint8_t command, data_length,type, pck_length;
/* Get the packet from radio */
pck_length = radio_read_data(packet);
/* Disassemble packet */
type = packet[0]; // Get TYPE of message
data_length = packet[1]; // Get LENGTH of data part
/* .... Room for decryption of message .... */
command = packet[DATA_POS]; // Get the received command
return command;
}
void radio_irq(void) interrupt RF_READY_INT_VECT
{
radio_interrupt();
}
void get_AD()
{
p=data_ov7660;
}
void main(void){
uint8_t command;
uint8_t ctr;
P0 = 0;
P0DIR = 0x0C;
RFCKEN = 1;
RF = 1; // enable RF interrupt
EA = 1; // Global interrupt enable
radio_init(1);
while(true)
{
while(radio_busy());
if(VSYNC=0)
{
if(HREF=1)
{
if(PCLK=1)
{
get_AD();
}
else
p++; // ++ 指针
}
else
{
send_packet(combuf[240]);
while(HREF=0);
}
}
else
send_packet(CMD1);
}
}
application.h 文件:
#define CMD_SEND_DAT
<< 上一页 [11] [12] [13] [14] [15] [16] 下一页