void Error() { if(CONTROL != ARBITRATION) { stop_bus(); } else { clear_int(); } }
/* * タイマの停止処理 */ void target_hrt_terminate(intptr_t exinf) { /* * OSタイマを停止する. */ sil_wrb_mem(OSTM_TT(OSTM0_BASE), OSTM_TT_STOP); /* * タイマ割込み要求をクリアする. */ clear_int(INTNO_OSTM0); }
/* * タイムウィンドウタイマの/オーバランタイマ初期化処理 */ void target_totimer_initialize(intptr_t exinf) { /* * OSタイマをインターバルタイマモードに設定する. */ sil_wrb_mem(OSTM_CTL(OSTM1_BASE), OSTM_CTL_INTERVAL); /* * タイムウィンドウタイマ割込み要求をクリアする. */ clear_int(INTNO_OSTM1); }
/* * 割込み要求ラインの属性の設定 * * ASPカーネルでの利用を想定して,パラメータエラーはアサーションでチェッ * クしている. */ Inline void config_int(INTNO intno, ATR intatr, PRI intpri) { assert(VALID_INTNO(intno)); assert(TMIN_INTPRI <= intpri && intpri <= TMAX_INTPRI); /* * 割込みを禁止 * * 割込みを受け付けたまま,レベルトリガ/エッジトリガの設定や,割 * 込み優先度の設定を行うのは危険なため,割込み属性にかかわらず, * 一旦マスクする. */ disable_int(intno); /* * 割込みをコンフィギュレーション */ #ifdef TOPPERS_SAFEG_SECURE gicd_config_group(intno, 1U); #endif /* TOPPERS_SAFEG_SECURE */ if ((intatr & TA_EDGE) != 0U) { #ifdef GIC_ARM11MPCORE gicd_config(intno, GICD_ICFGRn_EDGE|GICD_ICFGRn_1_N); #else /* GIC_ARM11MPCORE */ gicd_config(intno, GICD_ICFGRn_EDGE); #endif /* GIC_ARM11MPCORE */ clear_int(intno); } else { #ifdef GIC_ARM11MPCORE gicd_config(intno, GICD_ICFGRn_LEVEL|GICD_ICFGRn_1_N); #else /* GIC_ARM11MPCORE */ gicd_config(intno, GICD_ICFGRn_LEVEL); #endif /* GIC_ARM11MPCORE */ } /* * 割込み優先度とターゲットプロセッサを設定 */ gicd_set_priority(intno, INT_IPM(intpri)); gicd_set_target(intno, 1U << arm_prc_index()); /* * 割込みを許可 */ if ((intatr & TA_ENAINT) != 0U) { enable_int(intno); } }
static void OsNetworkHandle_SetInterrupted(OsNetworkHandle* aHandle, int aNewInterruptState) { OsMutexLock(aHandle->iMutex); if ( aNewInterruptState != (int) aHandle->iFlagInterrupted ) { aHandle->iFlagInterrupted = aNewInterruptState; #if INT_ENABLED if ( aHandle->iFlagInterrupted ) post_int(aHandle); else clear_int(aHandle); #endif } OsMutexUnlock(aHandle->iMutex); }
/* * タイマの起動処理 */ void target_hrt_initialize(intptr_t exinf) { /* * OSタイマをフリーランニングコンペアモードに設定する. */ sil_wrb_mem(OSTM_CTL(OSTM0_BASE), OSTM_CTL_FRCMP); /* * OSタイマの設定値を最大値にしておく. */ sil_wrw_mem(OSTM_CMP(OSTM0_BASE), 0xffffffff); /* * OSタイマを動作開始する. */ sil_wrb_mem(OSTM_TS(OSTM0_BASE), OSTM_TS_START); /* * タイマ割込み要求をクリアする. */ clear_int(INTNO_OSTM0); }
/** * @brief Enable a CPort that has a connected connection. */ static int configure_connected_cport(unsigned int cportid) { int ret = 0; struct cport *cport; unsigned int rc; irqstate_t flags; cport = cport_handle(cportid); if (!cport) { return -EINVAL; } rc = cport_get_status(cport); switch (rc) { case CPORT_STATUS_CONNECTED: cport->connected = 1; /* * Clear any pending EOM interrupts, then enable them. */ flags = irqsave(); clear_int(cportid); enable_int(cportid); irqrestore(flags); /* Start the flow of received data */ unipro_write(REG_RX_PAUSE_SIZE_00 + (cportid * sizeof(uint32_t)), (1 << 31) | CPORT_BUF_SIZE); break; case CPORT_STATUS_UNCONNECTED: ret = -ENOTCONN; break; default: lldbg("Unexpected status: CP%u: status: 0x%u\n", cportid, rc); ret = -EIO; } return ret; }
uint8_t TWI_send_status(uint8_t adr) { start_bus(); wait_for_bus(); if(CONTROL != START) { Error(); return 0; } send_data_and_wait(adr); if(CONTROL != ADDRESS_W) { Error(); return 0; } send_data_and_wait(I_STATUS); if(CONTROL == ARBITRATION) { clear_int(); return 1; } stop_bus(); return 1; }
int twocenters_kmeans (int DIMENSIONS, int CENTERS, int NUMBER_OF_RECORDS, float *records, float *centers, int *assigned_centers, int CSS_NUM_SPUS, int block_records) { /* Algorithm parameters */ int number_of_records; /* Auxiliary variables */ int k, i, j; int iteration, changed; /* Other computations */ int sizeofdistance; /* Data arrays */ float *newcenters; int *newcenters_histograms; /* Print precalculated information */ #ifdef KMEANS_DEBUG printf("K-MEANS called\n"); printf("Number of data points is %d\n", NUMBER_OF_RECORDS); printf("Number of centers is %d\n", CENTERS); printf("Number of dimensions %d\n\n", DIMENSIONS); #endif /* Allocate space for data */ newcenters = memalign(128, CENTERS * DIMENSIONS * sizeof(float)); newcenters_histograms = memalign(128, (CENTERS + 1) * sizeof(int)); /* Clear assigned centers */ memset(assigned_centers, -1, NUMBER_OF_RECORDS * sizeof(int)); changed = 0; iteration = 0; sizeofdistance = DIMENSIONS * 3 + 1; /* Main loop */ do { clear_float (newcenters, CENTERS*DIMENSIONS); clear_int (newcenters_histograms, CENTERS+1); for (i = 0; i < NUMBER_OF_RECORDS; i += block_records) { number_of_records = (i + block_records > NUMBER_OF_RECORDS ? NUMBER_OF_RECORDS - i : block_records); kmeans_calculate2(DIMENSIONS, CENTERS, number_of_records, &records[i * DIMENSIONS], centers, &assigned_centers[i], newcenters, newcenters_histograms); } iteration++; #pragma css wait on (newcenters_histograms) changed = newcenters_histograms[CENTERS]; if ((float) changed / NUMBER_OF_RECORDS < TERMINATION_THRESHOLD) { break; } if (iteration >= MAX_ITERATIONS_2KM) { break; } recalculate_centers_task(DIMENSIONS, CENTERS, centers, newcenters, newcenters_histograms); } while (1); #ifdef KMEANS_DEBUG printf("\nKmeans Number of ITERATIONS = #%d\n", iteration); #endif free(newcenters); free(newcenters_histograms); return 0; }
interrupt void PerformIsr1(void) { clear_int(4); c1++; }