本文整理汇总了C++中OUT_GPIO函数的典型用法代码示例。如果您正苦于以下问题:C++ OUT_GPIO函数的具体用法?C++ OUT_GPIO怎么用?C++ OUT_GPIO使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OUT_GPIO函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
int g,rep, i;
// Set up gpi pointer for direct register access
wiringPiSetupGpio ();
setup_io();
for (i = 0; i < 28; i++)
{
INP_GPIO(i);
printf("%d", GET_GPIO(i));
}
printf("\n");
//exit(0);
OUT_GPIO(INT); GPIO_SET(INT);
OUT_GPIO(NMI); GPIO_SET(NMI);
OUT_GPIO(CLK); GPIO_SET(CLK);
OUT_GPIO(WAIT); GPIO_SET(WAIT);
OUT_GPIO(BUSRQ); GPIO_SET(BUSRQ);
OUT_GPIO(RESET); GPIO_SET(RESET);
OUT_GPIO(SI); GPIO_SET(SI);
OUT_GPIO(CP); GPIO_SET(CP);
OUT_GPIO(CS_16); GPIO_SET(CS_16);
OUT_GPIO(M);
ResetSimulationVars();
WriteControlPins();
DoReset();
while(1)
loop();
}
示例2: initMotor
void initMotor(OUT_MOTOR* motor, char * n1, char* n2, char * file, int pinPWM, int pinIN1, int pinIN2, int pinSTBY, double vitesse){
motor->cap = fopen(file,"r");
motor->pinSTBY = pinSTBY;
motor->pinIN1 = pinIN1;
motor->pinIN2= pinIN2;
motor->pinPWM=pinPWM;
INP_GPIO(pinIN1);
INP_GPIO(pinIN2);
INP_GPIO(pinSTBY);
INP_GPIO(pinPWM);
OUT_GPIO(pinIN1);
OUT_GPIO(pinIN2);
OUT_GPIO(pinSTBY);
OUT_GPIO(pinPWM);
GPIO_SET = 1 << pinSTBY;
GPIO_CLR = 1 << pinIN1 | 1 << pinIN2 | 1<< pinPWM;
motor->vitesse=vitesse;
int err = rt_task_create(&(motor->task),n1, TASK_STKSZ, TASK_PRIO, TASK_MODE);
err |= rt_alarm_create(&(motor->alarm),n2);
err |= rt_task_set_periodic(&(motor->task), TM_NOW, PERIODE_MOTOR);
if (!err) {
rt_task_start(&(motor->task),&taskMotor,motor);
}
}
示例3: main
int main(int argc, char **argv) {
//int rep;
// Set up gpi pointer for direct register access
setup_io();
// GPIO23 - NTX2 enable
INP_GPIO(23); // must use INP_GPIO before we can use OUT_GPIO
OUT_GPIO(23);
// GPIO18 - NTX2 Data
INP_GPIO(18); // must use INP_GPIO before we can use OUT_GPIO
OUT_GPIO(18);
GPIO_SET = 1<<23;
char send[]="I'm growing a beard\n";
//for (rep=0; rep<8; rep++) {
int i;
for (i=0; i<strlen(send); i++){
domex_txbyte(send[i]);
}
//}
GPIO_CLR = 1<<23;
return 0;
}
示例4: bcm2835gpio_init
static int bcm2835gpio_init(void)
{
bitbang_interface = &bcm2835gpio_bitbang;
if (!is_gpio_valid(tdo_gpio) || !is_gpio_valid(tdi_gpio) ||
!is_gpio_valid(tck_gpio) || !is_gpio_valid(tms_gpio) ||
(trst_gpio != -1 && !is_gpio_valid(trst_gpio)) ||
(srst_gpio != -1 && !is_gpio_valid(srst_gpio)))
return ERROR_JTAG_INIT_FAILED;
dev_mem_fd = open("/dev/mem", O_RDWR | O_SYNC);
if (dev_mem_fd < 0) {
perror("open");
return ERROR_JTAG_INIT_FAILED;
}
pio_base = mmap(NULL, sysconf(_SC_PAGE_SIZE), PROT_READ | PROT_WRITE,
MAP_SHARED, dev_mem_fd, BCM2835_GPIO_BASE);
if (pio_base == MAP_FAILED) {
perror("mmap");
close(dev_mem_fd);
return ERROR_JTAG_INIT_FAILED;
}
tdo_gpio_mode = MODE_GPIO(tdo_gpio);
tdi_gpio_mode = MODE_GPIO(tdi_gpio);
tck_gpio_mode = MODE_GPIO(tck_gpio);
tms_gpio_mode = MODE_GPIO(tms_gpio);
/*
* Configure TDO as an input, and TDI, TCK, TMS, TRST, SRST
* as outputs. Drive TDI and TCK low, and TMS/TRST/SRST high.
*/
INP_GPIO(tdo_gpio);
GPIO_CLR = 1<<tdi_gpio | 1<<tck_gpio;
GPIO_SET = 1<<tms_gpio;
OUT_GPIO(tdi_gpio);
OUT_GPIO(tck_gpio);
OUT_GPIO(tms_gpio);
if (trst_gpio != -1) {
trst_gpio_mode = MODE_GPIO(trst_gpio);
GPIO_SET = 1 << trst_gpio;
OUT_GPIO(trst_gpio);
}
if (srst_gpio != -1) {
srst_gpio_mode = MODE_GPIO(srst_gpio);
GPIO_SET = 1 << srst_gpio;
OUT_GPIO(srst_gpio);
}
LOG_DEBUG("saved pinmux settings: tck %d tms %d tdi %d "
"tdo %d trst %d srst %d", tck_gpio_mode, tms_gpio_mode,
tdi_gpio_mode, tdo_gpio_mode, trst_gpio_mode, srst_gpio_mode);
return ERROR_OK;
}
示例5: printf
// Initialize pins/SPI for output
static PyObject *begin(DotStarObject *self) {
if(self->dataPin == 0xFF) { // Use hardware SPI
if((self->fd = open("/dev/spidev0.0", O_RDWR)) < 0) {
printf("Can't open /dev/spidev0.0 (try 'sudo')\n");
return NULL;
}
uint8_t mode = SPI_MODE_0 | SPI_NO_CS;
ioctl(self->fd, SPI_IOC_WR_MODE, &mode);
// The actual data rate may be less than requested.
// Hardware SPI speed is a function of the system core
// frequency and the smallest power-of-two prescaler
// that will not exceed the requested rate.
// e.g. 8 MHz request: 250 MHz / 32 = 7.8125 MHz.
ioctl(self->fd, SPI_IOC_WR_MAX_SPEED_HZ, self->bitrate);
xfer[0].tx_buf = (unsigned long)header;
xfer[2].tx_buf = (unsigned long)footer;
xfer[0].speed_hz = xfer[1].speed_hz = xfer[2].speed_hz =
self->bitrate;
} else { // Use bitbang "soft" SPI (any 2 pins)
if(gpio == NULL) { // First time accessing GPIO?
int fd;
if((fd = open("/dev/mem", O_RDWR | O_SYNC)) < 0) {
printf("Can't open /dev/mem (try 'sudo')\n");
return NULL;
}
isPi2 = (boardType() == 2);
gpio = (volatile unsigned *)mmap( // Memory-map I/O
NULL, // Any adddress will do
BLOCK_SIZE, // Mapped block length
PROT_READ|PROT_WRITE, // Enable read+write
MAP_SHARED, // Shared w/other processes
fd, // File to map
isPi2 ?
PI2_GPIO_BASE : // -> GPIO registers
PI1_GPIO_BASE);
close(fd); // Not needed after mmap()
if(gpio == MAP_FAILED) {
err("Can't mmap()");
return NULL;
}
gpioSet = &gpio[7];
gpioClr = &gpio[10];
}
self->dataMask = 1 << self->dataPin;
self->clockMask = 1 << self->clockPin;
// Set 2 pins as outputs. Must use INP before OUT.
INP_GPIO(self->dataPin); OUT_GPIO(self->dataPin);
INP_GPIO(self->clockPin); OUT_GPIO(self->clockPin);
*gpioClr = self->dataMask | self->clockMask; // data+clock LOW
}
Py_INCREF(Py_None);
return Py_None;
}
示例6: init
void init(uint8_t dataPin, uint8_t clockPin) {
setup_io();
INP_GPIO(dataPin); // must use INP_GPIO before we can use OUT_GPIO
OUT_GPIO(dataPin);
INP_GPIO(clockPin); // must use INP_GPIO before we can use OUT_GPIO
OUT_GPIO(clockPin);
}
示例7: userApp1
void userApp1(void * args)
{
int n_pin;
// set all the seg not to illume
for (n_pin = 0; n_pin < 8; ++n_pin){
INP_GPIO(pin[n_pin]);
OUT_GPIO(pin[n_pin]);
digitalWrite(pin[n_pin], HIGH);
}
// set all the node not to off
for(n_pin = 0; n_pin < 4; ++n_pin){
INP_GPIO(node[n_pin]);
OUT_GPIO(node[n_pin]);
digitalWrite(node[n_pin], LOW);
}
INP_GPIO(16);
OUT_GPIO(16);
int i_node = 0;
int disp_buffer[4] = {5, 0, 5, 0};
int disp_num = 0;
int last_dht11_dat0 = dht11_dat[0], last_dht11_dat2 = dht11_dat[2];
int i, update_flag;
while(1)
{
if(last_dht11_dat0 != dht11_dat[0] || last_dht11_dat2 != dht11_dat[2]){
disp_buffer[1] = dht11_dat[0]%10;
disp_buffer[0] = dht11_dat[0]/10;
disp_buffer[3] = dht11_dat[2]%10;
disp_buffer[2] = dht11_dat[2]/10;
}
last_dht11_dat0 = dht11_dat[0];
last_dht11_dat2 = dht11_dat[2];
digitalWrite(node[i_node], LOW);
i_node = (i_node+1) % 4;
disp_num = disp_buffer[i_node];
for(n_pin = 0; n_pin < 8; ++n_pin){
digitalWrite(pin[n_pin], digit[disp_num][n_pin]);
}
digitalWrite(node[i_node], HIGH);
//wtf_delay(100);
OSTimeDly(1);
}
}
示例8: setup_shiftreg
void setup_shiftreg()
{
// set SER to output
INP_GPIO(SER);
OUT_GPIO(SER);
// set SCLK to output
INP_GPIO(SCLK);
OUT_GPIO(SCLK);
// set RCLK to output
INP_GPIO(RCLK);
OUT_GPIO(RCLK);
}
示例9: main
int main(int argc, char **argv)
{
#ifdef DEMO_ENABLED
int g,rep;
#endif
/* Set up gpi pointer for direct register access */
setup_io();
#ifndef DEMO_ENABLED
/* Set GPIO pin 4 to output */
INP_GPIO(pin);
OUT_GPIO(pin);
#else
/* Set all exposed GPIO pins to output */
for (g = 0; g <= 32; g++)
{
if( ((1<<g) & 0x3e6cf93) != 0)
{
INP_GPIO(g);
OUT_GPIO(g);
}
}
GPIO_CLR = 0x3e6cf93; //clear all output pins
#endif
#ifdef DEMO_ENABLED
while (1)
{
for (rep = 0; rep < 14; rep++)
{
GPIO_SET = 1<<pins[rep];
printf("Set pin: %d\n", pins[rep]);
sleep(1);
GPIO_CLR = 1<<pins[rep];
printf("Clear pin: %d\n", pins[rep]);
sleep(1);
}
}
#else
while (1)
{
GPIO_SET = 1<<pin;
printf("Set pin: %d\n", pin);
sleep(1);
GPIO_CLR = 1<<pin;
printf("Clear pin: %d\n", pin);
sleep(1);
}
#endif
return 0;
}
示例10: main
int main()
{
int g,rep;
setup_io(); /*Direct Register access*/
#if 0
/*Set gpio 7..11 to outpu mode*/
for(g=7; g <= 18; g++)
{
INP_GPIO(g);
OUT_GPIO(g);
}
#endif
INP_GPIO(17);
OUT_GPIO(17);
while(1)
{
GPIO_SET = 1 << 17;
//delay(500);
sleep(1);
GPIO_CLR = 1 << 17;
//delay(500);
sleep(1);
}
#if 0
for (rep=0; rep=10; rep++)
{
for(g=7; g <= 11; g++)
{
GPIO_SET = 1 << g;
sleep(1);
}
for(g=7; g<= 11; g++)
{
GPIO_CLR = 1 << g;
sleep(1);
}
}
#endif
}
示例11: rpi_gpio_open
int rpi_gpio_open(struct rtdm_dev_context *context, rtdm_user_info_t *user_info, int oflags)
{
struct rpi_gpio_context *ctx;
ctx = (struct rpi_gpio_context *) context->dev_private;
ctx->gpio_addr = virt_addr;
ctx->gpio_rt = gpio_rt;
ctx->gpio_nrt = gpio_nrt;
OUT_GPIO(ctx->gpio_addr, ctx->gpio_rt);
OUT_GPIO(ctx->gpio_addr, ctx->gpio_nrt);
return 0;
}
示例12: init_module
/**
* init_module() - This function is called when the module is loaded
*
* Return: On succes the function retuns a 0 (SUCCES). Otherwise a
* negative number is returned.
*/
int init_module(void)
{
Major = register_chrdev(0, DEVICE_NAME, &fops);
if (Major < 0)
{
printk(KERN_ALERT "Registering char device failed with %d\n", Major);
return Major;
}
printk(KERN_INFO "I was assigned major number %d. To talk to\n", Major);
printk(KERN_INFO "the driver, create a device file with\n");
printk(KERN_INFO "'mknod /dev/%s c %d 0'.\n", DEVICE_NAME, Major);
printk(KERN_INFO "Try various minor numbers. Try to cat and echo to\n");
printk(KERN_INFO "the device file.\n");
printk(KERN_INFO "Remove the device file and module when done.\n");
// Map GPIO
gpio.map = ioremap(GPIO_BASE, 1); //Gives a pointer to the first GPIO register
gpio.addr = (volatile unsigned int *)gpio.map;
// Set pin directions for the LED
INP_GPIO(GPIO_LED);
OUT_GPIO(GPIO_LED);
return SUCCESS;
}
示例13: gpioSetPin
//
// Configure GPIOs as input or output
//
void gpioSetPin(uint8_t pin, uint8_t dir) {
// Set pin number to given direction
INP_GPIO(pin); // Must make pin an input first, even for output
if (dir == GPIO_OUTPUT)
OUT_GPIO(pin);
}
示例14: main
int
main()
{
if(init_gpio() == -1)
{
printf("Failed to map the physical GPIO registers into the virtual memory space.\n");
return (-1);
}
printf("Helloblink is started with GIOP%d at pin number 8.\n", LED_PIN);
// Define gpio 4 (LED) as output
INP_GPIO(LED_PIN);
OUT_GPIO(LED_PIN);
while(1)
{
GPIO_SET(LED_PIN);
usleep(100 * 1000);
GPIO_CLR(LED_PIN);
usleep(100 * 1000);
}
return 0;
}
示例15: printf
bool HWAbstraction::setupIO() {
int memFd;
/* open /dev/mem */
if ((memFd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
printf("can't open /dev/mem \n");
return false;
}
/* mmap GPIO */
m_gpioMap = mmap(
NULL, //Any adddress in our space will do
BLOCK_SIZE, //Map length
PROT_READ|PROT_WRITE,// Enable reading & writting to mapped memory
MAP_SHARED, //Shared with other processes
memFd, //File to map
GPIO_BASE //Offset to GPIO peripheral
);
close(memFd); //No need to keep mem_fd open after mmap
if (m_gpioMap == MAP_FAILED) {
printf("mmap error %p\n", m_gpioMap);//errno also set!
return false;
}
// Always use volatile pointer!
m_gpio = (volatile unsigned *)m_gpioMap;
INP_GPIO(25);
OUT_GPIO(25);
return true;
} // setup_io