If you look closely at the error text you'll see you misspelt "write" as
"wirte".
On 27 Jul 2014 04:10, <[email protected]> wrote:
> /sys/class/gpio/export this driver file i have used.
>
> but this control only one bit. so, i try to 8bit control like this
>
> #include "bb_gpio.h"
> #include <stdio.h>
> #include <sys/time.h>
> //#include <string.h>
>
> void main(void)
> {
> gpio_export(p9_11); gpio_export(p9_12);
> gpio_export(p9_13); gpio_export(p9_14);
> gpio_export(p9_15); gpio_export(p9_16);
> gpio_export(p9_17); gpio_export(p9_18);
>
> gpio_direction(p9_11,out); gpio_direction(p9_12,out);
> gpio_direction(p9_13,out); gpio_direction(p9_14,out);
> gpio_direction(p9_15,out); gpio_direction(p9_16,out);
> gpio_direction(p9_17,out); gpio_direction(p9_18,out);
> while(1){
> pin_write(p9_11,1); pin_write(p9_12,1);
> pin_write(p9_13,1); pin_write(p9_14,1);
> pin_write(p9_15,1); pin_write(p9_16,1);
> pin_write(p9_17,1); pin_write(p9_18,1);
> sleep(1);
> pin_write(p9_11,0); pin_wirte(p9_12,0);
> pin_write(p9_13,0); pin_wirte(p9_14,0);
> pin_write(p9_15,0); pin_wirte(p9_16,0);
> pin_write(p9_17,0); pin_wirte(p9_18,0);
> sleep(1);
> };
> }
>
>
> ================#include "bb_gpio.h"================
>
> #ifndef BB_GPIO_H_
> #define BB_GPIO_H_
>
> #include <stdio.h>
> #include <string.h>
>
> /********************************************
> * BB_GPIO headerfile
> * This file only used to gpio control
> * other feature using device-tree-overlay
> * when using GPIO, the pin work to MODE7
> *=====formula======
> * GPIO N1[N2]
> * gpio_number = (32 x N1) + N2
> *==================
> *********************************************/
>
> #define out 1
> #define in 0
>
> #define export_PATH "/sys/class/gpio/export"
> #define value_PATH "/sys/class/gpio/gpio%d/value"
> #define direction_PATH "/sys/class/gpio/gpio%d/direction"
> #define unexport_PATH "/sys/class/gpio/unexport"
>
> //*********************P9***********************
> #define p9_11 30
> #define p9_12 60
> #define p9_13 31
> #define p9_14 50
> #define p9_15 48
> #define p9_16 51
> #define p9_17 5
> #define p9_18 4
> //#define p9_19 13
> //#define p9_20 12
> #define p9_21 3
> #define P9_22 2
> #define p9_23 49
> #define p9_24 15
> #define p9_25 117
> #define p9_26 14
> #define p9_27 115
> //#define p9_28 113
> //#define p9_29 111
> #define p9_30 112
> //#define p9_31 110
> #define p9_41 20
> //#define p9_41 116
> //#define p9_42 114
> #define p9_42 7
> //*********************************************
>
>
> //*********************P8***********************
> //*********************************************
>
>
>
> //******************function*********************
> int gpio_export(int);
> int gpio_unexport(int);
> int gpio_direction(int, int);
> int pin_write(int, int);
> int pin_read(int);
> //***********************************************
>
>
> #endif /*BB_GPIO_*/
>
> int gpio_export(int gpio_number)
> {
> FILE* fp=0;
>
> if((fp = fopen(export_PATH,"w"))==NULL){
> printf("Cannot open export file(>>%s).\n", export_PATH);
> return -1;
> }
> fprintf(fp,"%d",gpio_number);
> fclose(fp);
> }
>
> int gpio_unexport(int gpio_number)
> {
> FILE* fp;
>
> if((fp = fopen(unexport_PATH,"w"))==NULL){
> printf("Cannot open unexport file(>>%s).\n", unexport_PATH);
> return -1;
> }
> fprintf(fp,"%d",gpio_number);
> fclose(fp);
> }
>
> int gpio_direction(int gpio_number,int direction)
> {
> FILE* fp;
> char set_value[4]={0};
> char dir_path[50]={0};
> sprintf(dir_path, direction_PATH, gpio_number);
> if((fp = fopen(dir_path,"w"))==NULL){
> printf("Cannot open direction file(>>%s).\n",dir_path);
> return -1;
> }
> rewind(fp);
> if(direction == out){
> strcpy(set_value,"out");
> fwrite(&set_value,sizeof(char),3,fp);
> fclose(fp);
> } else if(direction == in){
> strcpy(set_value,"in");
> fwrite(&set_value,sizeof(char),2,fp);
> fclose(fp);
> } else{
> printf("invalue pin mode(%d)\n",direction);
> return -1;
> }
> fclose(fp);
> return 1;
> }
>
> int pin_write(int gpio_number,int value)
> {
> FILE* fp;
> char val_path[50]={0};
> char set_value[2]={0};
>
> sprintf(val_path, value_PATH, gpio_number);
> if((fp = fopen(val_path,"w"))==NULL){
> printf("Cannot open value file(>>%s).\n",val_path);
> return -1;
> }
>
> rewind(fp);
> if(value == 1){
> strcpy(set_value,"1");
> }
> else if(value == 0){
> strcpy(set_value,"0");
> }
> else {
> printf("invalid value pin(%d)(%d)\n", gpio_number, value);
> return -1;
> }
>
> fwrite(&set_value, sizeof(char), 1, fp);
> fclose(fp);
> return 0;
> }
>
> int pin_read(int gpio_number)
> {
> FILE* fp;
> int value=0;
> char val_path[50]={0};
>
> sprintf(val_path, value_PATH, gpio_number);
> if((fp = fopen(val_path,"r"))==NULL){
> printf("Cannot open value file(>>%s).\n",val_path);
> return -1;
> }
>
> rewind(fp);
> value = fgetc(fp) - '0';
> fclose(fp);
> return value;
> }
>
>
>
>
> but compile error...
>
> root@beaglebone:/home/debian/workspace/sources/gpio_control# \
> > gcc -o led_blink led_blink.c
> /tmp/ccfrwmlk.o: In function `main':
> led_blink.c:(.text+0x5c8): undefined reference to `pin_wirte'
> led_blink.c:(.text+0x5e0): undefined reference to `pin_wirte'
> led_blink.c:(.text+0x5f8): undefined reference to `pin_wirte'
> led_blink.c:(.text+0x610): undefined reference to `pin_wirte'
> collect2: ld returned 1 exit status
> root@beaglebone:/home/debian/workspace/sources/gpio_control#
>
> i don't know why .. help please
>
> --
> For more options, visit http://beagleboard.org/discuss
> ---
> You received this message because you are subscribed to the Google Groups
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.