1 #include <AT91SAM7S64.h>
2 #include <interrupt-utils.h>
4 #include <debug-uart.h>
8 #include <dev/cc2420_const.h>
12 #include <sys/procinit.h>
18 #include <stepper-steps.h>
20 #include <stepper-move.h>
37 #include "net/uip-fw-drv.h"
41 {
UIP_FW_NETIF(172,16,0,0, 255,255,0,0, uip_over_mesh_send)};
43 #define UIP_OVER_MESH_CHANNEL 9
47 static rimeaddr_t node_addr = {{0,2}};
49 extern char __heap_end__;
50 extern char __heap_start__;
53 static const uint32_t stepper0_steps_acc[] = MICRO_STEP(0,3);
54 static const uint32_t stepper0_steps_run[] = MICRO_STEP(0,2);
55 static const uint32_t stepper0_steps_hold[] = MICRO_STEP(0,1);
57 static const uint32_t stepper1_steps_acc[] = MICRO_STEP(1,3);
58 static const uint32_t stepper1_steps_run[] = MICRO_STEP(1,2);
59 static const uint32_t stepper1_steps_hold[] = MICRO_STEP(1,1);
61 static StepperAccSeq seq_heap[40];
67 for(i = 0; i <
sizeof(seq_heap)/
sizeof(seq_heap[0]); i++) {
68 seq_heap[i].next =
NULL;
69 stepper_free_seq(&seq_heap[i]);
77 stepper_init(AT91C_BASE_TC0, AT91C_ID_TC0);
78 *AT91C_PIOA_OER = STEPPER_INHIBIT;
79 *AT91C_PIOA_MDER = STEPPER_INHIBIT;
80 *AT91C_PIOA_CODR = STEPPER_INHIBIT;
81 stepper_init_io(1, STEPPER_IOMASK(0), stepper0_steps_acc,
82 stepper0_steps_run, stepper0_steps_hold,
83 (
sizeof(stepper0_steps_run) /
sizeof(stepper0_steps_run[0])));
84 stepper_init_io(0, STEPPER_IOMASK(1), stepper1_steps_acc,
85 stepper1_steps_run, stepper1_steps_hold,
86 (
sizeof(stepper1_steps_run) /
sizeof(stepper1_steps_run[0])));}
101 *AT91C_WDTC_WDCR = (0xa5<<24) | AT91C_WDTC_WDRSTT;
114 *AT91C_AIC_IDCR = 0xffffffff;
115 *AT91C_PMC_PCDR = 0xffffffff;
116 *AT91C_PMC_PCER = (1 << AT91C_ID_PIOA);
119 printf(
"Initialising\n");
126 robot_stepper_init();
131 cc2420_set_pan_addr(0x2024, 0, &uip_hostaddr.u16[1]);
132 cc2420_set_channel(RF_CHANNEL);
134 printf(
"CC2420 setup done\n");
148 printf(
"Host addr\n");
151 uip_over_mesh_set_net(&hostaddr, &netmask);
155 printf(
"Mesh init\n");
156 uip_over_mesh_init(UIP_OVER_MESH_CHANNEL);
157 printf(
"uIP started with IP address %d.%d.%d.%d\n",
168 printf(
"Heap size: %ld bytes\n", &__heap_end__ - (
char*)sbrk(0));
171 autostart_start(autostart_processes);
172 printf(
"Processes running\n");
180 *AT91C_PMC_SCDR |= AT91C_PMC_PCK;