void Adc_SetAsyncMode(void) /* Use this interface only if Interrupt generation is supported */ { /* enable interrupt */ DMA_SRC0.U = SRPN_DMA_SRC0 | BITPOS(12); DMA_SRC1.U = SRPN_DMA_SRC1 | BITPOS(12); DMA_SRC2.U = SRPN_DMA_SRC2 | BITPOS(12); DMA_SRC3.U = SRPN_DMA_SRC3 | BITPOS(12); }
/* adds a new edge to graph */ void graph_add_edge (graph_t *g, int a, int b) { int aa, bb; unsigned long pos = 0; aa = a%g->nodes; bb = b%g->nodes; pos = (unsigned long)BITPOS(aa,bb,g->nodes); BitTrue(g->barray,pos); }
nbrs_t * graph_node_nbrs (graph_t *g, int node) { unsigned int aa, bb; int i, j; unsigned long pos; int nodes; int nsize; nbrs_t *nb; nsize = graph_node_degree (g, node); nb = (nbrs_t *) malloc (sizeof (nbrs_t)); if (!nb) { fprintf (stderr, "no enough memory abort\n"); _FLINE_; exit (0); } nb->size = nsize; nb->id = node; nb->nbrs = (int *) malloc (sizeof(int) * nsize); if (!nb->nbrs) { fprintf (stderr, "no enough memory abort %s %d\n", __FILE__, __LINE__); exit (0); } bzero(nb->nbrs, sizeof(int)*nsize); if (!nsize) { return nb; } nodes = g->nodes; j = 0; for (i = 0; ((i < nodes) && (nsize)); i++) { aa = (unsigned int)i; bb = (unsigned int)node; pos = (unsigned long)BITPOS(aa,bb,nodes); if ((node != i) && (BitIsTrue(g->barray,pos))) { nb->nbrs[j++] = i; nsize --; } } return nb; }
int graph_is_edge (graph_t *g, int a, int b) { int aa, bb; unsigned long pos; aa = a; bb = b; if (a == b) { return 0; } pos = (unsigned long)BITPOS(aa, bb, g->nodes); return (int)BitValue(g->barray, pos); }
/* returns degress of a node */ int graph_node_degree (graph_t *g, int a) { int i, n; unsigned int aa, bb; unsigned long pos; n = 0; for (i = 0; i < g->nodes; i++) { aa = (unsigned int)a; bb = (unsigned int)i; pos = 0; pos = (unsigned long)BITPOS(aa,bb,g->nodes); if (BitValue(g->barray,pos) && (a != i)) { n++; } } return n; }
void print_graph (graph_t *g) { int n; int i; unsigned long pos; int j = 0; n = g->nodes; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { if (j > i) { pos = (unsigned long)BITPOS(i,j,g->nodes); if (BitValue(g->barray, pos)) { printf ("e %2d %2d\n", i, j); } } } } }