void TEST_LightMCU() {
    char rx[10];
    unsigned int i, r, g, b, final;
    while (1) {
        uprint("l to loop, other for special");
        rx[0] = uart1Rx();

        if (rx[0] == 'l') {
            for (i = 0; i < 192; i ++) {
                uprint_int("Sending ", i);
                sendLightMCU(i);
                DELAY_MS(50);
            }
        } else {
            uprint("Enter r 0-4: ");
            uart1_gets(rx, 10);
            r = atoi(rx);
            uprint("Enter g 0-4: ");
            uart1_gets(rx, 10);
            g = atoi(rx);
            uprint("Enter b 0-4: ");
            uart1_gets(rx, 10);
            b = atoi(rx);

            final = 0b11000000 + (r << 4) + (g << 2) + b;

            uprint_int("Sending ", final);

            sendLightMCU(final);
        }
    }
示例#2
0
文件: main.c 项目: Nakrez/zOS
int main(void)
{
    struct video *driver_implem;

    uprint("Video: Launching driver");

    if (!(driver_implem = malloc(sizeof (struct video))))
    {
        uprint("Video: Out of memory");

        return 1;
    }

    if (video_initialize(driver_implem) < 0)
    {
        free(driver_implem);

        return 1;
    }

    driver_implem->opened = 0;

    uprint("Video: Initialization successful");

    return video_driver_run(driver_implem);
}
void TEST_RadioSend() {
    char rx[2];
    while (1) {
        uprint("Enter character to send: ");
        uart1_gets(rx, 1);
        radioSendMessage(rx, 0x0A00);
        uprint("Sent message!");
    }
}
void TEST_RadioReceive() {
    char rx[2];
    while (1) {
        uprint("Wating for message ...");

        radioGetMessage(rx, 1);

        uprint("Got message: ");
        uprint(rx);
    }
}
示例#5
0
static SDev*
aoeprobe(char *path, SDev *s)
{
    int n, i;
    char *p;
    Chan *c;
    Ctlr *ctlr;

    if((p = strrchr(path, '/')) == 0)
        error(Ebadarg);
    *p = 0;
    uprint("%s/ctl", path);
    *p = '/';

    c = namec(up->genbuf, Aopen, OWRITE, 0);
    if(waserror()) {
        cclose(c);
        nexterror();
    }
    n = uprint("discover %s", p+1);
    devtab[c->type]->write(c, up->genbuf, n, 0);
    poperror();
    cclose(c);

    for(i = 0;; i += Probeintvl) {
        if(i > Probemax || waserror())
            error(Etimedout);
        tsleep(&up->sleep, return0, 0, Probeintvl);
        poperror();

        uprint("%s/ident", path);
        if(waserror())
            continue;
        c = namec(up->genbuf, Aopen, OREAD, 0);
        poperror();
        cclose(c);

        ctlr = newctlr(path);
        break;
    }

    if(s == nil && (s = malloc(sizeof *s)) == nil)
        return nil;
    s->ctlr = ctlr;
    s->ifc = &sdaoeifc;
    s->nunit = 1;
    return s;
}
示例#6
0
文件: protocol.c 项目: cuu/weiyi
void set_coordi(void)
{
    uint8 logicalType;

        osal_nv_item_init( ZCD_NV_LOGICAL_TYPE, sizeof(logicalType), &logicalType );
        logicalType = ZG_DEVICETYPE_COORDINATOR;
        if( osal_nv_write( ZCD_NV_LOGICAL_TYPE, 0 ,sizeof(logicalType), &logicalType) != ZSUCCESS)
        {
          uprint("set device to coordi failed");
        }else
        {
          zgWriteStartupOptions (ZG_STARTUP_SET, ZCD_STARTOPT_DEFAULT_NETWORK_STATE);
          uprint("set device to coordi,restart it");
        }         
        return; 
}
示例#7
0
文件: fp_trig.c 项目: 0-T-0/ps4-linux
struct fp_ext *
fp_fsincos7(struct fp_ext *dest, struct fp_ext *src)
{
	uprint("fsincos7\n");

	return dest;
}
示例#8
0
/* Format the date */
static void
date(const UChar *tz,
     UDateFormatStyle style,
     char *format,
     UErrorCode *status)
{
  UChar *s = 0;
  int32_t len = 0;
  UDateFormat *fmt;
  UChar uFormat[100];

  fmt = udat_open(style, style, 0, tz, -1,NULL,0, status);
  if ( format != NULL ) {
     u_charsToUChars(format,uFormat,strlen(format)),
     udat_applyPattern(fmt,FALSE,uFormat,strlen(format));
  }
  len = udat_format(fmt, ucal_getNow(), 0, len, 0, status);
  if(*status == U_BUFFER_OVERFLOW_ERROR) {
    *status = U_ZERO_ERROR;
    s = (UChar*) malloc(sizeof(UChar) * (len+1));
    if(s == 0) goto finish;
    udat_format(fmt, ucal_getNow(), s, len + 1, 0, status);
    if(U_FAILURE(*status)) goto finish;
  }

  /* print the date string */
  uprint(s, stdout, status);

  /* print a trailing newline */
  printf("\n");

 finish:
  udat_close(fmt);
  free(s);
}
示例#9
0
/* Version information */
static void
version()
{
  UErrorCode status = U_ZERO_ERROR;
  const char *tzVer;
  int len = 256;
  UChar tzName[256];
  printf("icudate version %s, created by Stephen F. Booth.\n", 
	 DATE_VERSION);
  puts(U_COPYRIGHT_STRING);
  tzVer = ucal_getTZDataVersion(&status);
  if(U_FAILURE(status)) {  
      tzVer = u_errorName(status);  
  }
  printf("\n");
  printf("ICU Version:               %s\n", U_ICU_VERSION);
  printf("ICU Data (major+min):      %s\n", U_ICUDATA_NAME);
  printf("Default Locale:            %s\n", uloc_getDefault());
  printf("Time Zone Data Version:    %s\n", tzVer);
  printf("Default Time Zone:         ");
  status = U_ZERO_ERROR;
  u_init(&status);
  len = ucal_getDefaultTimeZone(tzName, len, &status);
  if(U_FAILURE(status)) {
    printf(" ** Error getting default zone: %s\n", u_errorName(status));
  }
  uprint(tzName, stdout, &status);
  printf("\n\n");
}
示例#10
0
static int
identify(Ctlr *c, ushort *id)
{
    uchar oserial[21];
    vlong osectors, s;

    osectors = c->sectors;
    memmove(oserial, c->serial, sizeof c->serial);
    s = idfeat(c, id);
    if(s == -1) {
        uprint("%s: identify fails", c->unit->name);
        print("%s\n", up->genbuf);
        error(up->genbuf);
    }
    idmove(c->serial, id+10, 20);
    idmove(c->firmware, id+23, 8);
    idmove(c->model, id+27, 40);

    if((osectors == 0 || osectors != s) &&
            memcmp(oserial, c->serial, sizeof oserial) != 0) {
        c->sectors = s;
        c->drivechange = 1;
        c->vers++;
    }
    return 0;
}
示例#11
0
/* must call with d qlocked */
static int
aoeidentify(Ctlr *d, SDunit *u)
{
	Chan *c;

	c = nil;
	if(waserror()){
		if(c)
			cclose(c);
		iprint("aoeidentify: %s\n", up->errstr);
		nexterror();
	}

	uprint("%s/ident", d->path);
	c = namec(up->genbuf, Aopen, OREAD, 0);
	devtab[c->type]->read(c, d->ident, sizeof d->ident, 0);

	poperror();
	cclose(c);

	d->feat = 0;
	d->smart = 0;
	identify(d, (ushort*)d->ident);

	memset(u->inquiry, 0, sizeof u->inquiry);
	u->inquiry[2] = 2;
	u->inquiry[3] = 2;
	u->inquiry[4] = sizeof u->inquiry - 4;
	memmove(u->inquiry+8, d->model, 40);

	return 0;
}
示例#12
0
文件: bst.c 项目: MintPaw/College
/* (*uprint) user provided print function */
void inorder(struct node_t *node, void (*uprint)(void *, void *))
{
   if (node != NULL) {
	   inorder(node->left, uprint);
	   uprint(node->key, node->value);
	   inorder(node->right, uprint);
   }
}
示例#13
0
void TEST_Audio() {
    char rx[50];
    unsigned char vol;
    unsigned int snd;
    while (1) {
        uprint("Enter volume level: ");
        uart1_gets(rx, 50);
        vol = atoi(rx);
        uprint_int("Volume is: ", vol);
        uprint("Enter sound: ");
        uart1_gets(rx, 50);
        snd = atoi(rx);
        uprint_int("Sound is: ", snd);
        setVolume(vol);
        playSound(snd);
    }
}
示例#14
0
文件: fp_log.c 项目: E-LLP/n900
struct fp_ext *
fp_flog2(struct fp_ext *dest, struct fp_ext *src)
{
	uprint("flog2\n");

	fp_monadic_check(dest, src);

	return dest;
}
示例#15
0
文件: fp_log.c 项目: E-LLP/n900
struct fp_ext *
fp_ftentox(struct fp_ext *dest, struct fp_ext *src)
{
	uprint("ftentox\n");

	fp_monadic_check(dest, src);

	return dest;
}
示例#16
0
文件: fp_trig.c 项目: 0-T-0/ps4-linux
struct fp_ext *
fp_fcosh(struct fp_ext *dest, struct fp_ext *src)
{
	uprint("fcosh\n");

	fp_monadic_check(dest, src);

	return dest;
}
示例#17
0
文件: fp_trig.c 项目: 0-T-0/ps4-linux
struct fp_ext *
fp_fatan(struct fp_ext *dest, struct fp_ext *src)
{
	uprint("fatan\n");

	fp_monadic_check(dest, src);

	return dest;
}
示例#18
0
文件: fp_log.c 项目: 08opt/linux
struct fp_ext *
fp_fetoxm1(struct fp_ext *dest, struct fp_ext *src)
{
	uprint("fetoxm1\n");

	fp_monadic_check(dest, src);

	return dest;
}
示例#19
0
文件: printf.c 项目: hchunhui/myos
int printf(const char* fmt,...)
{
	va_list args;
	int i;
	char buf[500];
	va_start(args,fmt);
	i=vsprintf(buf,fmt,args);
	va_end(args);
	uprint(buf);
	return i;
}
示例#20
0
文件: protocol.c 项目: cuu/weiyi
void set_router(void)
{
    uint8 logicalType;
          osal_nv_item_init( ZCD_NV_LOGICAL_TYPE, sizeof(logicalType), &logicalType );
          logicalType = ZG_DEVICETYPE_ROUTER;
          if( osal_nv_write( ZCD_NV_LOGICAL_TYPE, 0 ,sizeof(logicalType), &logicalType) != ZSUCCESS)
          {
            uprint("set device to router failed");
          }else
          {
            zgWriteStartupOptions (ZG_STARTUP_SET, ZCD_STARTOPT_DEFAULT_NETWORK_STATE);
            uprint("set device to router,restart it");
          }
          
//          zgWriteStartupOptions (ZG_STARTUP_SET, 0x02);
//          zgInit();
//          ZDOInitDevice( 0 );
//          SystemReset();   
          return;  
}
示例#21
0
文件: inode_cache.c 项目: Nakrez/zOS
struct ext2_inode *ext2_icache_request(struct ext2fs *ext2, ino_t inode)
{
    int i;
    uint64_t group;
    uint64_t index;
    int ret;
    struct fiu_instance *fi = ext2->fi;

    for (i = 0; i < EXT2_INODE_CACHE_SIZE; ++i) {
        if (ext2->inode_cache[i].inode == inode) {
            ++ext2->inode_cache[i].ref_count;
            return &(ext2->inode_cache[i].cinode);
        }
    }

    /*
     * If the inode was not in cache, we find a place to hold it in the cache
     * and we fetch it
     */

    for (i = 0; i < EXT2_INODE_CACHE_SIZE; ++i) {
        if (ext2->inode_cache[i].inode == EXT2_BAD_INODE ||
            ext2->inode_cache[i].ref_count == 0)
            break;
    }

    /* No place to hold it */
    if (i == EXT2_INODE_CACHE_SIZE) {
        uprint("EXT2: Cache is full! FIXME!");
        return NULL;
    }

    index = (inode - 1) % ext2->sb.inode_per_group;
    group = (inode - 1) / ext2->sb.inode_per_group;

    off_t lseek_off = (off_t)ext2->grp_table[group].inode_table *
                      ext2->block_size + index * ext2->sb.sizeof_inode;

    ret = lseek(fi->device_fd, lseek_off, SEEK_SET);
    if (ret < 0)
        return NULL;

    ret = read(fi->device_fd, &ext2->inode_cache[i].cinode,
               sizeof (struct ext2_inode));
    if (ret < 0)
        return NULL;

    ext2->inode_cache[i].inode = inode;
    ext2->inode_cache[i].ref_count = 1;

    return &ext2->inode_cache[i].cinode;
}
示例#22
0
void cloudMain() {

    uprint("\r\n ************************ BOOT UP (CLOUD) ************************ \r\n");

    configureAudio();
    audioReset();
    
    configureIRSend();
    int sta = configureRadio(0x0A00, 0x0000111111111111);
    uprint_int("Configured radio: ", sta);

    char rxbuf[2];
    int damageToSend, i;

    configureCloudLighting();

    DELAY_MS(400);

    playSound(CS_BOOT);
    DELAY_MS(CS_BOOT_LEN);


    while (1) {

        uprint("Beginning of main loop");
        cloudLightingSetMode(ALGM_BLINK);

        uprint("Waiting for hammer message");
        radioGetMessage(rxbuf, 1);

        uprint("Got message");

        playSound(CS_FIRE);
        // Don't wait for this sound

        // Enter manual lighting mode
        cloudLightingSetMode(ALGM_OFF);
        cloudLightingSetAll(BRIGHTNESS_MAX);
        cloudLightingUpdate();

        damageToSend = rxbuf[0];
        for (i = 0; i < damageToSend; i ++) {
            uprint("Sending damage packet");
            sendDamagePacket();
            if ((i % 10) == 0) {
                cloudLightingSetAll(BRIGHTNESS_MAX);
            } else if ((i % 5) == 0) {
                cloudLightingSetAll(50);
            }
            cloudLightingUpdate();
        }

        uprint("Sending DONE message");
        radioSendMessage("DONE", 0x0A00);

    }
    
}
示例#23
0
文件: main.c 项目: Nakrez/zOS
int main(void)
{
    int tid;

    if (ide_detect(&ide) < 0)
    {
        uprint("ATA: No IDE controller found. Bye!");

        return 1;
    }

    if (!ide_initialize(&ide))
    {
        uprint("ATA: No disk have been detected. Bye!");

        return 2;
    }

    uprint("ATA: configuration detected, creating devices ...");

    for (int i = 0; i < 4; ++i)
    {
        if (ide.devices[i].exists)
        {
            tid = thread_create(driver_device_thread, 1, &ide.devices[i]);

            if (tid < 0)
                uprint("ATA: Fail to start thread");
        }
    }

    while (1)
        sleep(1);

    return 0;
}
示例#24
0
/* Print the days */
static void
print_days(UChar *days [],
           FILE *f,
           UErrorCode *status)
{
    int32_t i;

    if(U_FAILURE(*status)) return;

    /* Print the day names */
    for(i = 0; i < DAY_COUNT; ++i) {
        uprint(days[i], f, status);
        putc(' ', f);
    }
}
示例#25
0
文件: devaoe.c 项目: Earnestly/plan9
static Aoedev*
unit2dev(ulong unit)
{
	int i;
	Aoedev *d;

	rlock(&devs);
	i = 0;
	for(d = devs.d; d; d = d->next)
		if(i++ == unit){
			runlock(&devs);
			return d;
		}
	runlock(&devs);
	uprint("unit lookup failure: %lux pc %#p", unit, getcallerpc(&unit));
	error(up->genbuf);
	return nil;
}
示例#26
0
文件: GenericApp.c 项目: cuu/weiyi
/*********************************************************************
 * @fn      GenericApp_ProcessZDOMsgs()
 *
 * @brief   Process response messages
 *
 * @param   none
 *
 * @return  none
 */
static void GenericApp_ProcessZDOMsgs( zdoIncomingMsg_t *inMsg )
{
  switch ( inMsg->clusterID )
  {
    case End_Device_Bind_rsp:
      if ( ZDO_ParseBindRsp( inMsg ) == ZSuccess )
      {
        // Light LED
        HalLedSet( HAL_LED_2, HAL_LED_MODE_ON );
      }
#if defined( BLINK_LEDS )
      else
      {
        // Flash LED to show failure
        HalLedSet ( HAL_LED_2, HAL_LED_MODE_FLASH );
      }
#endif
      break;

    case Match_Desc_rsp:
      {
        uprint("Match_Decs_rsp");
        ZDO_ActiveEndpointRsp_t *pRsp = ZDO_ParseEPListRsp( inMsg );
        if ( pRsp )
        {
          if ( pRsp->status == ZSuccess && pRsp->cnt )
          {
            GenericApp_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
            //GenericApp_DstAddr.addr.shortAddr = pRsp->nwkAddr;
            GenericApp_DstAddr.addr.shortAddr = 0xFFFF;
            
            // Take the first endpoint, Can be changed to search through endpoints
            GenericApp_DstAddr.endPoint = pRsp->epList[0];

            // Light LED
            //HalLedSet( HAL_LED_2, HAL_LED_MODE_ON );
          }
          osal_mem_free( pRsp );
        }
      }
      break;
  }
}
示例#27
0
文件: protocol.c 项目: cuu/weiyi
void set_panid( uint16 u16NewPanid)
{
  uint8 u8BackCode;
  _NIB.nwkPanId = u16NewPanid;
  macRadioSetPanID ( _NIB.nwkPanId);
  ZMacSetReq( ZMacPanId, (byte *)& _NIB.nwkPanId);
  
  u8BackCode = osal_nv_write(ZCD_NV_PANID, 0, 2, &u16NewPanid);
  if( u8BackCode == ZSUCCESS)
  {
    NLME_UpdateNV(0x01);
//    HAL_SYSTEM_RESET();
  }
  else
  {
    uprint("set_panid failed");
  }
  
}
示例#28
0
/*
**	subtest_ul(test_list, status, ch)
**
**	test transparent underline (ul)
*/
static void
subtest_ul(
	struct test_list *t,
	int *state,
	int *ch)
{
	if (!over_strike) {
		/* (ul) is used only if (os) is reset */
		put_crlf();
		sprintf(temp, "This text should %sbe underlined.",
			transparent_underline ? "" : "not ");
		uprint(temp);
		put_crlf();
		ptextln("If the above line is not underlined the (ul) should be false.");
		sprintf(temp, "(ul) Transparent-underline is %s in the data base",
			transparent_underline ? "true" : "false");
		ptextln(temp);
		generic_done_message(t, state, ch);
	}
}
示例#29
0
static void
aoectl(Ctlr *d, char *s)
{
    Chan *c;

    c = nil;
    if(waserror()) {
        if(c)
            cclose(c);
        print("sdaoectl: %s\n", up->errstr);
        nexterror();
    }

    uprint("%s/ctl", d->path);
    c = namec(up->genbuf, Aopen, OWRITE, 0);
    devtab[c->type]->write(c, s, strlen(s), 0);

    poperror();
    cclose(c);
}
示例#30
0
static int
aoeconnect(SDunit *u, Ctlr *c)
{
	qlock(c);
	if(waserror()){
		qunlock(c);
		return -1;
	}

	aoeidentify(u->dev->ctlr, u);
	if(c->c)
		cclose(c->c);
	c->c = 0;
	uprint("%s/data", c->path);
	c->c = namec(up->genbuf, Aopen, ORDWR, 0);
	qunlock(c);
	poperror();

	return 0;
}