void init(void)
{
	// this is a initialization for set the input and output of PIC18F2685
	// User is advised NOT to change the setting here
	// tris
	TRISB=0x00;				// led as output
	TRISA=0xff;				// push button as input
	TRISC=0x00;				// set port c as output
	
	// the setting for analog to digital converter, ADC for PIC18F2685
	// User is advised NOT to change the setting here
	// adc
	ADCON1=0x0F;
	
	//call the initialization function of I2C
	iic_init();		
	
	//	set the initial condition of output device on board
	//	User is advised not to change the initial condition
	led=0x00;				// turn OFF all LED on board by sending value '0x00'
	buzzer=0;				// turn OFF buzzer on board by sending value '0'
	error_led=0;			// turn OFF Error LED on board by sending value '0'
	busy_led=1;				// turn ON Busy LED on board by sending value '1'
	slave_reset=1;			// reset slave cards
	delay(10000);			
	slave_reset=0;			
	delay(50000);			
	busy_led=0;				// turn OFF Busy LED on board by sending value '0'
}
Exemple #2
0
void iic_start(void)
{
  iic_init();
  SCL_1;
  SDA_1;
  _NOP();
  SDA_0;
}
Exemple #3
0
void iic_stop(void)
{
  iic_init();
  SCL_1;
  SDA_0;
  _NOP();
  SDA_1;
}
Exemple #4
0
/**
 * @brief 
 * @param 
 * @retval 
 */
static void device_init(void)
{
	port_init();
#ifdef INTERFACE_4WIRE_SPI
	spi1_init();
#endif
	iic_init();
	adc1_init();
}
Exemple #5
0
bool_t pmu_init(void)
{
	u8_t val;

	iic_init();

	if(pmu_read(0x31, &val))
		pmu_write(0x31, val & 0xf8);

	return TRUE;
}
Exemple #6
0
void main()
{
  
  RCC_Configuration(); // Configure the system clocks
  GPIO_Configuration(); //GPIO configuration
  NVIC_Configuration(); //NVIC Configuration
  Timer_Configuration();
  
  iic_init();
  //ov2640_jpeg_config(JPEG_800x600);
 
  ov2640_jpeg_config(JPEG_640x480);
  
  //ov2640_jpeg_config(JPEG_320x240);
   /* 设置COMS参数 */
   ov2640_brightness_config(0x40);
   ov2640_auto_exposure(3);//3
   ov2640_contrast_config(0x28, 0x0c);
   ov2640_black_white_config(0x00);
   ov2640_color_saturation(0x68, 0x68);
    ov2640_light_mode_config(OFFICE);
   o2640_capture_gpio_init();

   /* 关闭像素同步中断 */
  ov2640_interrupt_disable();
  USART1_Init(); //115200@8-n-1
  //UART4_Init(38400);//camera
  printf("MCU initialized.\r\n");
  Reset_W5500();
  printf("Ethernet initialized over.\r\n");
  WIZ_SPI_Init();
  
  set_network();
  
  printf("W5500 is ready!\r\n");
  
  printf("camera init......OK\r\n");
  
  JPEGCnt=0;
  ov2640_interrupt_enable();
  
  while(1)
  {
    do_websocket_server(SOCK_WEBSOCKET);
    
    do_http();
    
  }
}
Exemple #7
0
int main(void)
{
char rec;
unsigned char value = 0;

printf("\n\r\n\r");

iic_init();

printf("\n\r");
iic_master_write(0xa0, 0x3, 0x15);
iic_master_read(0xa0, 0x3, &value);
printf("addr 0x3 value is: ");
uart_asm_putx(value);
printf("\n\r");

iic_dest();
 
return 0;
}
Exemple #8
0
void iic_test()
{
	uint8_t cnt;
	uint8_t data;
	struct _at24c08_addr_data  at24c08_addr_data;
	iic_init();
	for(cnt=0;cnt<4;cnt++)
	{
		at24c08_addr_data.addr =cnt;
		at24c08_addr_data.data = (cnt+2);
		iic_master_trans_one_char(at24c08_addr_data);
	}
	//read
	for(cnt=0;cnt<256;cnt++)
	{
		at24c08_addr_data.addr = cnt;
		data=iic_master_recv_one_char(cnt);
		dbg_printf("iic data :%d\r\n",data);
	}
	
}
Exemple #9
0
/*
 * IIC Abort Transaction
 */
int iic_reset_init_abort(XIicPs *IicPs, u16 DeviceId, u32 ClkRate) {
	//Variables
//	int i = 0;

//	//Check if IIC is busy
//	while (XIicPs_BusIsBusy(IicPs)) {
//		i++;
//		if (i >= 1000) {
//#ifdef DEBUG
//			myprintf("Cannot abort IIC Transaction because IIC is busy.\r\n");
//#endif
//			return XST_FAILURE;
//		}
//	}

//Reset and Init
//	XIicPs_ResetHw(IIC_BASE_ADDR);
	iic_init(IicPs, IIC_DEVICE_ID, IIC_SCLK_RATE);
//	XIicPs_Reset(IicPs);

//Abort and return
	XIicPs_Abort(IicPs);
	return XST_SUCCESS;
}
Exemple #10
0
static void iic_reset(struct i2c_algo_iic_data *adap)
{
	iic_outw(adap, PM_IBSR, iic_inw(adap, PM_IBSR) | 0x80);
	iic_init(adap);
}
Exemple #11
0
/*
 * Description: After we issue a transaction on the IIC bus, this function
 * is called.  It puts this process to sleep until we get an interrupt from
 * from the controller telling us that the transaction we requested in complete.
 */
static int
wait_for_pin(struct i2c_adapter *adap, int *status)
{

	int timeout = DEF_TIMEOUT;
	int retval;
	struct iic_regs *iic;

	iic = (struct iic_regs *) IIC_DEV(vaddr);

	*status = iic_inb(iic->sts);
#ifndef STUB_I2C

	while (timeout-- && (*status & 0x01)) {
		iic_ibmocp_waitforpin(adap->data);
		*status = iic_inb(iic->sts);
	}
#endif
	if (timeout <= 0) {
		/* Issue stop signal on the bus, and force an interrupt */
		retval = iic_inb(iic->cntl);
		iic_outb(iic->cntl, retval | 0x80);
		/* Clear status register */
		iic_outb(iic->sts, 0x0a);
		/* Exit unknown bus state */
		retval = iic_inb(iic->mdcntl);
		iic_outb(iic->mdcntl, (retval | 0x02));
#if 1 /* MVL */

		/*
		 * Looks like a delay is needed prior to checking 
		 * IIC0_STS[PT] after the above.
		 */

		udelay(500);
#endif /* MVL */

		/* Check the status of the controller.  Does it still see a
		 * pending transfer, even though we've tried to stop any
		 * ongoing transaction?
		 */
		retval = iic_inb(iic->sts);
		retval = retval & 0x01;
		if (retval) {
			/* The iic controller is hosed.  It is not responding to any
			 * of our commands.  We have already tried to force it into
			 * a known state, but it has not worked.  Our only choice now
			 * is a soft reset, which will clear all registers, and force
			 * us to re-initialize the controller.
			 * Soft reset
			 */
			iic_outb(iic->xtcntlss, 0x01);
			udelay(500);
			iic_init(adap);
			/* Is the pending transfer bit in the sts reg finally cleared? */
			retval = iic_inb(iic->sts);
			retval = retval & 0x01;
			if (retval) {
				printk(KERN_CRIT
				       "The IIC Controller is hosed.  A processor reset is required\n");
			}
			/* For some reason, even though the interrupt bit in this
			 * register was set during iic_init, it didn't take.  We
			 * need to set it again.  Don't ask me why....this is just what
			 * I saw when testing timeouts.
			 */
			iic_outb(iic->intmsk, 0x01);

#if 1 /* MVL */
			/*
			 * Similar comments as above for clkdiv.
			 */

			iic_outb(iic->clkdiv, 0x04);
#endif /* MVL */
		}
		return (-1);
	} else
		return (0);
}
Exemple #12
0
static void gsl_hw_init(void)
{
    iic_init();
}
Exemple #13
0
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
{
	iic_init();
    return JNI_VERSION_1_4;
}