Jump to content

Ribster

Members
  • Posts

    8
  • Joined

  • Last visited

Everything posted by Ribster

  1. msev, just try it. Get the pinning out from the orange pi zero and try what works. If you cannot get things to work, you can always provide stuff you tried with examples and then you can be helped in a specific way.
  2. Since it is python on the A20, you can search the web for examples. They do exist. Even in the official python docs. It's not that hard. You can always make a push request for that A20 python repo to add your examples once you figured it out. https://pypi.python.org/pypi/pyA20
  3. So i'm stupid as fuck... Why did i not add the main function.... Got it working! For future reference: test.c file: #include <stdlib.h> #include <stdio.h> #include <time.h> #include "gpio_lib.h" int main(){ int ret; ret = sunxi_gpio_init(); ret = sunxi_gpio_set_cfgpin(SUNXI_GPA(17), SUNXI_GPIO_OUTPUT); while(1) { sunxi_gpio_output(SUNXI_GPA(17), 1); usleep(100000); sunxi_gpio_output(SUNXI_GPA(17), 0); usleep(100000); sunxi_gpio_output(SUNXI_GPA(17), 1); usleep(100000); sunxi_gpio_output(SUNXI_GPA(17), 0); usleep(600000); } } the command line compile: gcc test.c gpio_lib.c -o test Then just ./test and the red led will blink!! Next step: get this working in the kernel driver...
  4. Okay great, this is very valuable. I understand the spidev as it gets mounted and you can just use it like a file system. I guess if i want to make a kernel module, i can just address them by bus 0 and bus 1 and use the spi kernel api to move further. Am i right that i need to delete the spidev@0 { compatible = "spidev"; reg = <0x0>; spi-max-frequency = <1000000>; }; part for using it with my own kernel module ? Else it gets mounted to the spidev ? Edit: Too fast. I will need to remove this piece : // Enable the spidev interface /dts-v1/; /plugin/;
  5. Yes, i've got the python blinky sketch working. Changed the mapping.h for the correct io and was up and running. i've tried a simple c file, but i've got some errors. Once i get this up and running, i can port it to my kernel module... my test.c #include <stdlib.h> #include <stdio.h> #include "gpio_lib.h" sunxi_gpio_init(); sunxi_gpio_set_cfgpin(SUNXI_GPA(17), SUNXI_GPIO_OUTPUT); while(1) { sunxi_gpio_output(SUNXI_GPA(17), 1); sleep(1); sunxi_gpio_output(SUNXI_GPA(17), 0); sleep(1); } and the shell output root@OPI-3:~/git/orangepi_PC_gpio_pyH3/pyA20/gpio# gcc -O test.c test.c:5:1: warning: data definition has no type or storage class sunxi_gpio_init(); ^ In file included from test.c:3:0: gpio_lib.h:122:24: error: expected declaration specifiers or ‘...’ before ‘(’ token #define SUNXI_GPA(_nr) (SUNXI_GPIO_A_START + (_nr)) ^ test.c:6:23: note: in expansion of macro ‘SUNXI_GPA’ sunxi_gpio_set_cfgpin(SUNXI_GPA(17), SUNXI_GPIO_OUTPUT); ^ gpio_lib.h:143:27: error: expected declaration specifiers or ‘...’ before ‘(’ token #define SUNXI_GPIO_OUTPUT (1) ^ test.c:6:38: note: in expansion of macro ‘SUNXI_GPIO_OUTPUT’ sunxi_gpio_set_cfgpin(SUNXI_GPA(17), SUNXI_GPIO_OUTPUT); ^ test.c:7:1: error: expected identifier or ‘(’ before ‘while’ while(1) { ^
  6. Update: I found out that the pyA20 library has some interfacing stuff that can be used. Investigating this to get it build in c with gcc so i can make some leds blink. https://github.com/duxingkei33/orangepi_PC_gpio_pyH3
  7. Hey Martin, In a related question, i'm trying to get the GPIO / SPI working with pi zero. I'm used to A13, so have experience with fex. The objective is to move to mainline tho, but it's pretty hard to find good info what steps to take etc. So my question is: for mainline zero GPIO / SPI access in kernel space(preferably) or user space, where can i find good guides / tutorials ? Thanks in advance!
  8. Hey everybody. I'm quite new to allwinner, my first experience was with the A13 (sun4i) from olimex. I wrote a kernel driver for the sunxi kernel, which uses the spi and some GPIO. It talks to an SPI RF chip and works just fine. I want to port my kernel driver for the Orange Pi Zero, but have some issues. My main question is: how do i access the fex file, how do i manipulate the gpio and spi ? In the sun4i there are helper functions in the arch/arm/mach-sun4i/sys_config.c file. #define PIN_DIR(handler,dir) gpio_set_one_pin_io_status(handler, dir, NULL) #define PIN_SET(handler,val) gpio_write_one_pin_value(handler, val, NULL) #define PIN_GET(handler) gpio_read_one_pin_value(handler, NULL) I don't seem to get them in the sun8i sys_config.c file that is located in #include <mach/sys_config.h> I normally get the gpio pins as such: my_sx1272_data->pin_led = gpio_request_ex("sx1272_para", "pin_led"); And i manipulate the IO with these defines, that also use the functions from sys_config. PIN_DIR(my_sx1272_data->pin_led, PIN_DIR_OUT); PIN_SET(my_sx1272_data->pin_led, 0); For the SPI i use this way of setup, i guess this will work, but i need to get rid of the sys_config implicit function compilation error first. struct spi_board_info spi_device_info = { .modalias = "DURALINK", .max_speed_hz = 350*1000, //speed your device (slave) can handle .bus_num = 2, .chip_select = 0, .mode = 0, }; master = spi_busnum_to_master( spi_device_info.bus_num ); if( !master ){ printk(KERN_ERR "[LoRa] MASTER not found.\n"); return -ENODEV; } // create a new slave device, given the master and device info spi_device = spi_new_device( master, &spi_device_info ); if( !spi_device ) { printk(KERN_ERR "[LoRa] FAILED to create slave.\n"); return -ENODEV; } spi_device->bits_per_word = 8; ret = spi_setup( spi_device ); if( ret ){ printk(KERN_ERR "[LoRa] FAILED to setup slave.\n"); spi_unregister_device( spi_device ); return -ENODEV; } Currently using Linux OPI-3.4.113 3.4.113-sun8i #50 SMP PREEMPT Mon Nov 14 08:41:55 CET 2016 armv7l GNU/Linux So it's the Debian armbian image 3.4.113. Thanks in advance.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines