int main(void) { int del; iolib_init(); /* Initialize I/O library - required */ iolib_setdir(8,11, BBBIO_DIR_IN); /* Set pin P8 - 11 as input */ iolib_setdir(8,12, BBBIO_DIR_OUT); /* Set pin P8 - 12 as output */ int count = 0; while(count < 50) { count ++ ; if (is_high(8,11)) /* Check if in is high (i.e. button pressed) */ { del=100; /* fast speed */ } if (is_low(8,11)) /* Check if in is low (i.e button is released) */ { del=500; /* slow speed */ } pin_high(8,12); /* Set pin to high - LED on */ iolib_delay_ms(del); /* Delay for 'del' msec */ pin_low(8,12); /* Set pin to low - LED off */ iolib_delay_ms(del); /* Delay for 'del' msec */ } iolib_free(); /* Release I/O library prior to program exit - required */ return(0); }
int producerth2(void){ int count = 0; int flag=0; iolib_setdir(8,12, BBBIO_DIR_IN); /* Set pin P8 - 11 as input */ while(count < 10) { char l='R'; iolib_delay_ms(100); if (is_high(8,12)) /* Check if in is high (i.e. button pressed) */ { if (flag==1) { flag=0; enqueue(l,count+10); count++; continue; } else continue; } if (is_low(8,12)) /* Check if in is low (i.e button is released) */ { if (flag==0) { flag=1; } else continue; } } return 0; }
void send_buzz(){ printf("send buzz\n"); //Set image on device system(fanny_buzz_image_path); int delay = 500; int count = 3; int i = 0; while(i < count){ pin_high(8,39); iolib_delay_ms(delay); //Half a second pin_low(8,39); iolib_delay_ms(delay); //Half a second i++; } system(black_image_path); //Set black image on device }
int ADT7301_read() { int value = 0; int data_count =0; int i =0 ; pin_high(ADT7301_SCLK_PORT,ADT7301_SCLK_PIN); value =0; //set CS to 1 , why pin_low ? because CS in ADT7301 is inverse pin pin_low(ADT7301_CS_PORT,ADT7301_CS_PIN); //set DIN to 0 pin_low(ADT7301_DIN_PORT,ADT7301_DIN_PIN); //read temperature Data for(i=0;i<16;i++) { //generate half cycle(1) pin_low(ADT7301_SCLK_PORT ,ADT7301_SCLK_PIN); iolib_delay_ms(1); //generate half cycle(0) pin_high(ADT7301_SCLK_PORT,ADT7301_SCLK_PIN); iolib_delay_ms(1); value <<= 1 ; int get_value = is_high(ADT7301_DOUT_PORT,ADT7301_DOUT_PIN) ; value |= get_value; } //set CS to 1 pin_high(ADT7301_CS_PORT,ADT7301_CS_PIN); // return RAW value , this valuse is return value ; }
//----------------------------------------------------------------- int main(void) { int del =5; iolib_init(); printf("init finish\n"); /* BBBIO_GPIO_set_dir(BBBIO_GPIO1 , 0 , BBBIO_GPIO_PIN_12 | BBBIO_GPIO_PIN_13 | BBBIO_GPIO_PIN_14 | BBBIO_GPIO_PIN_15 ); */ BBBIO_sys_Enable_GPIO(BBBIO_GPIO2); iolib_setdir(8,11, BBBIO_DIR_OUT); // Scan A iolib_setdir(8,12, BBBIO_DIR_OUT); // Scan B iolib_setdir(8,15, BBBIO_DIR_OUT); // Scan C iolib_setdir(8,16, BBBIO_DIR_OUT); // Scan D iolib_setdir(8,39, BBBIO_DIR_OUT); // Seg A iolib_setdir(8,40, BBBIO_DIR_OUT); // Seg B iolib_setdir(8,41, BBBIO_DIR_OUT); // Seg C iolib_setdir(8,42, BBBIO_DIR_OUT); // Seg D iolib_setdir(8,43, BBBIO_DIR_OUT); // Seg E iolib_setdir(8,44, BBBIO_DIR_OUT); // Seg F iolib_setdir(8,45, BBBIO_DIR_OUT); // Seg G iolib_setdir(8,46, BBBIO_DIR_OUT); // Seg . (point) printf("OK"); int count = 0; int DisplayNumber =1234 ; while(count < 200) { count ++ ; pin_low(8,11); Display_Number(DisplayNumber / 1000); iolib_delay_ms(del); pin_high(8,11); pin_low(8,12); Display_Number(DisplayNumber / 100); iolib_delay_ms(del); pin_high(8,12); pin_low(8,15); Display_Number(DisplayNumber / 10); iolib_delay_ms(del); pin_high(8,15); pin_low(8,16); Display_Number(DisplayNumber); iolib_delay_ms(del); pin_high(8,16); } BBBIO_sys_Disable_GPIO(BBBIO_GPIO2); iolib_free(); return(0); }