You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							48 lines
						
					
					
						
							1.2 KiB
						
					
					
				
			
		
		
	
	
							48 lines
						
					
					
						
							1.2 KiB
						
					
					
				| #include <stdio.h> | |
| #include "pico/stdlib.h" | |
| #include "hardware/spi.h" | |
| #include "hardware/dma.h" | |
| #include "hardware/pio.h" | |
| #include "hardware/timer.h" | |
|  | |
| // SPI Defines | |
| // We are going to use SPI 0, and allocate it to the following GPIO pins | |
| // Pins can be changed, see the GPIO function select table in the datasheet for information on GPIO assignments | |
| #define SPI_PORT spi0 | |
| #define PIN_MISO 16 | |
| #define PIN_CS   17 | |
| #define PIN_SCK  18 | |
| #define PIN_MOSI 19 | |
|  | |
| int64_t alarm_callback(alarm_id_t id, void *user_data) { | |
|     // Put your timeout handler code in here | |
|     return 0; | |
| } | |
|  | |
|  | |
|  | |
| int main() | |
| { | |
|     stdio_init_all(); | |
|  | |
|     // SPI initialisation. This example will use SPI at 1MHz. | |
|     spi_init(SPI_PORT, 1000*1000); | |
|     gpio_set_function(PIN_MISO, GPIO_FUNC_SPI); | |
|     gpio_set_function(PIN_CS,   GPIO_FUNC_SIO); | |
|     gpio_set_function(PIN_SCK,  GPIO_FUNC_SPI); | |
|     gpio_set_function(PIN_MOSI, GPIO_FUNC_SPI); | |
|      | |
|     // Chip select is active-low, so we'll initialise it to a driven-high state | |
|     gpio_set_dir(PIN_CS, GPIO_OUT); | |
|     gpio_put(PIN_CS, 1); | |
|      | |
|  | |
|  | |
|  | |
|     // Timer example code - This example fires off the callback after 2000ms | |
|     add_alarm_in_ms(2000, alarm_callback, NULL, false); | |
|  | |
|     puts("Hello, world!"); | |
|  | |
|     return 0; | |
| }
 | |
| 
 |