Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *** RaspiVid.c 2014-07-29 20:21:13.070434559 +0000
- --- ../userland/host_applications/linux/apps/raspicam/RaspiVid.c 2014-07-28 11:03:29.787283376 +0000
- ***************
- *** 75,122 ****
- #include <semaphore.h>
- - #include <bcm2835.h>
- - #define BCM2835_GPIO_FSEL_INPT 0
- - #define BCM2835_GPIO_FSEL_ALT0 4
- -
- - void release_i2c_access(void)
- - {
- - bcm2835_init();
- - bcm2835_gpio_fsel(0, BCM2835_GPIO_FSEL_INPT);
- - bcm2835_gpio_fsel(1, BCM2835_GPIO_FSEL_INPT);
- - bcm2835_gpio_fsel(28, BCM2835_GPIO_FSEL_INPT);
- - bcm2835_gpio_fsel(29, BCM2835_GPIO_FSEL_INPT);
- - bcm2835_gpio_fsel(28, BCM2835_GPIO_FSEL_ALT3);
- - bcm2835_gpio_set_pud(28, BCM2835_GPIO_PUD_UP);
- - bcm2835_gpio_fsel(29, BCM2835_GPIO_FSEL_ALT3);
- - bcm2835_gpio_set_pud(29, BCM2835_GPIO_PUD_UP);
- -
- - uint16_t clk_div = BCM2835_I2C_CLOCK_DIVIDER_2500;
- - uint8_t slave_address = 0x36;
- - bcm2835_i2c_setSlaveAddress(slave_address);
- - bcm2835_i2c_setClockDivider(clk_div);
- - bcm2835_i2c_begin();
- - bcm2835_i2c_end();
- - }
- -
- - void claim_i2c_access(void)
- - {
- - bcm2835_init();
- - bcm2835_gpio_fsel(0, BCM2835_GPIO_FSEL_INPT);
- - bcm2835_gpio_fsel(1, BCM2835_GPIO_FSEL_INPT);
- - bcm2835_gpio_fsel(28, BCM2835_GPIO_FSEL_INPT);
- - bcm2835_gpio_fsel(29, BCM2835_GPIO_FSEL_INPT);
- - bcm2835_gpio_fsel(28, BCM2835_GPIO_FSEL_ALT0);
- - bcm2835_gpio_set_pud(28, BCM2835_GPIO_PUD_UP);
- - bcm2835_gpio_fsel(29, BCM2835_GPIO_FSEL_ALT0);
- - bcm2835_gpio_set_pud(29, BCM2835_GPIO_PUD_UP);
- -
- - uint16_t clk_div = BCM2835_I2C_CLOCK_DIVIDER_2500;
- - uint8_t slave_address = 0x36;
- - bcm2835_i2c_setSlaveAddress(slave_address);
- - bcm2835_i2c_setClockDivider(clk_div);
- - }
- -
- /// Camera number to use - we only have one camera, indexed from 0.
- #define CAMERA_NUMBER 0
- --- 75,80 ----
- ***************
- *** 1664,1671 ****
- */
- int main(int argc, const char **argv)
- {
- - release_i2c_access();
- -
- // Our main data storage vessel..
- RASPIVID_STATE state;
- int exit_code = EX_OK;
- --- 1622,1627 ----
- ***************
- *** 1975,2006 ****
- }
- else
- {
- ! while(1) {
- ! char line[80];
- ! char *buffer;
- ! buffer = line;
- ! size_t sz = 80;
- ! fprintf(stderr, "Press just enter to set exposure mode off, or enter 6 hex digits, first 4 are address, next 2 are value.\n");
- ! int r = getline(&buffer, &sz, stdin);
- ! if (r>1){
- ! int x;
- ! sscanf(line,"%x",&x);
- ! int addr = (x&0xFFFF00)>>8;
- ! int val = x & 0xFF;
- ! fprintf(stderr, "set register %x to %x\n", addr, val);
- ! uint8_t data;
- ! char wbuf[4];
- ! wbuf[0] = addr>>8;
- ! wbuf[1] = addr;
- ! wbuf[2] = val;
- ! data = bcm2835_i2c_write(wbuf, 3);
- ! fprintf(stderr,"Write Result = %d\n", data);
- ! } else {
- ! fprintf(stderr, "exposure off, claiming i2c interface\n");
- ! MMAL_PARAMETER_EXPOSUREMODE_T exp_mode = {{MMAL_PARAMETER_EXPOSURE_MODE,sizeof(exp_mode)}, MMAL_PARAM_EXPOSUREMODE_OFF};
- ! mmal_status_to_int(mmal_port_parameter_set(camera_video_port->component->control, &exp_mode.hdr));
- ! claim_i2c_access();
- ! }
- }
- }
- }
- --- 1931,1943 ----
- }
- else
- {
- ! if (state.timeout)
- ! vcos_sleep(state.timeout);
- ! else
- ! {
- ! // timeout = 0 so run forever
- ! while(1)
- ! vcos_sleep(ABORT_INTERVAL);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement