AMX amx; cell ret =0; int result = 0; memset(&amx, 0, sizeof(amx)); result = amx_Init(&amx,bulkData); if (result != 0) { // handle error } result = amx_NativeInit(&amx); if (result != 0) { // handle error } result = amx_Exec(&amx,&ret,AMX_EXEC_MAIN); if (result != 0) // handle error else { // handle success ! // return ret } |
static cell amx_toggle_GPIO(AMX *amx, const cell *params) { /* params[1] = port * params[2] = pin * params[3] = value */ LPC_GPIO[params[1]]->FIODIR |= 1<<params[2]; if (params[3] == 0) LPC_GPIO[params[1]]->FIOCLR |= 1<<params[2]; else LPC_GPIO[params[1]]->FIOSET |= 1<<params[2]; return SUCCESS; } int amx_NativeInit(AMX *amx) { static AMX_NATIVE_INFO nativesFcn[]= { {"toggleGPIO", amx_toggle_GPIO}, {0,0} /* terminator */ }; return amx_Register(amx, nativesFcn, -1); } |