Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * std lib headers
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <stdint.h>
- /*
- * libmaple headers
- */
- #include <wirish.h>
- #include <dma.h> // direct memory access
- /*
- * nano Open Sound Control lib
- * continuous music controller lib
- */
- extern "C" {
- #include <nosc.h>
- #include <cmc.h>
- #include <fix16.h>
- #include <dma_udp.h>
- }
- uint8_t mac [] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
- uint8_t ip [] = {192, 168, 1, 177};
- uint8_t gateway [] = {192, 168, 1, 1};
- uint8_t subnet [] = {255, 255, 255, 0};
- uint8_t sock = 0;
- uint16_t port = 3333;
- uint8_t remote_ip [] = {192, 168, 1, 255};
- uint16_t remote_port = 3333;
- static uint8_t buf [1024];
- HardwareSPI spi(2);
- extern "C"{
- void initSS ()
- {
- pinMode (BOARD_SPI2_NSS_PIN, OUTPUT);
- }
- void setSS ()
- {
- digitalWrite (BOARD_SPI2_NSS_PIN, 0); // enable wiz820io
- }
- void resetSS ()
- {
- digitalWrite (BOARD_SPI2_NSS_PIN, 1); // dsable wiz820io
- }
- }
- void
- loop ()
- {
- dma_udp_send (sock, buf, 1024);
- }
- void
- setup ()
- {
- pinMode (BOARD_BUTTON_PIN, INPUT);
- pinMode (BOARD_LED_PIN, OUTPUT);
- delay(300);
- spi.begin (SPI_18MHZ, MSBFIRST, 0);
- initSS ();
- dma_init (DMA1);
- spi_rx_dma_enable (SPI2); // Enables TX DMA on SPI2
- spi_tx_dma_enable (SPI2); // Enables TX DMA on SPI2
- // set up dma_udp
- dma_udp_init (mac, ip, gateway, subnet);
- dma_udp_begin (sock, port);
- dma_udp_set_remote (sock, remote_ip, remote_port);
- }
- __attribute__ ((constructor)) void
- premain ()
- {
- init ();
- }
- int
- main (void)
- {
- setup ();
- while (true)
- loop ();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement