예제 #1
0
void stm32_wlinitialize(void)
{
#  ifndef CONFIG_STM32_SPI2
#   error "STM32_SPI2 is required to support nRF24L01 module on this board"
#  endif

  int result;
  FAR struct spi_dev_s *spidev;

  /* Setup CE & IRQ line IOs */

  stm32_configgpio(GPIO_NRF24L01_CE);
  stm32_configgpio(GPIO_NRF24L01_IRQ);

  /* Init SPI bus */

  spidev = stm32_spibus_initialize(2);
  if (!spidev)
    {
      _err("ERROR: Failed to initialize SPI bus\n");
      return;
    }

  result = nrf24l01_register(spidev, &nrf_cfg);
  if (result != OK)
    {
      _err("ERROR: Failed to register initialize SPI bus\n");
      return;
    }
}
예제 #2
0
// Construct the chunker.
K7Chunker::K7Chunker(const ConfigNode& config) : AbstractChunker(config)
{
    // Check the configuration type matches the class name.
    if (config.type() != "K7Chunker")
    {
        throw _err("K7Chunker::K7Chunker(): Invalid or missing XML configuration.");
    }

    // Packet dimensions.
    _packetSize = sizeof(K7Packet);
    _headerSize = sizeof(K7Packet::Header);
    // Number of packets per chunk (pipeline iteration).
    _nPackets = config.getOption("udpPacketsPerIteration", "value", "128").toUInt();
    // Number of Nyquist-sampled values leaving F-engines per second.
    _packetsPerSecond = 390625;

    // Total number of channels per incoming packet.
    _nChannels = config.getOption("channelsPerPacket", "value", "1024").toUInt();

    // Channel range for the output stream (counted from 0).
    _channelStart = config.getOption("stream", "channelStart", "0").toUInt();
    _channelEnd = config.getOption("stream", "channelEnd", "1023").toUInt();
    if ( (_channelEnd >= _nChannels) || (_channelStart >= _channelEnd) || (_channelStart < 0) || (_channelEnd < 0) )
    {
        throw _err("K7Chunker::K7Chunker(): Invalid channel ranges.");
    }
    std::cout << "K7Chunker::K7Chunker(): _channelStart " << _channelStart << std::endl;
    std::cout << "K7Chunker::K7Chunker(): _channelEnd " << _channelEnd << std::endl;

    // Calculate the size of the packet for the output stream...
    _streamChannels = _channelEnd - _channelStart + 1;
    std::cout << "K7Chunker::K7Chunker(): _streamChannels " << _streamChannels << std::endl;

    // Since there is only one sample per packet and no raw polarizations but pseudo-Stokes both values are 1.
    _packetSizeStream = _streamChannels * sizeof(uint64_t) + _headerSize;
    std::cout << "K7Chunker::K7Chunker(): _packetSizeStream " << _packetSizeStream << std::endl;

    // ...and the output streams.
    _bytesStream = _packetSizeStream - _headerSize;
    std::cout << "K7Chunker::K7Chunker(): _bytesStream " << _bytesStream << std::endl;
    _byte1OfStream = _channelStart * sizeof(uint64_t);
    std::cout << "K7Chunker::K7Chunker(): _byte1OfStream " << _byte1OfStream << std::endl;

    // Initialise class variables.
    _startTimestamp = 0;
    _startAccumulation = 0;
    _packetsAccepted = 0;
    _packetsRejected = 0;

    // Set the empty packet data for stream.
    memset((void*)_emptyPacket.data, 0, _bytesStream);
    _emptyPacket.header.UTCtimestamp = 0;
    _emptyPacket.header.accumulationNumber = 0;
    _emptyPacket.header.accumulationRate = 0;

    // Set the chunk processed counter.
    _chunksProcessed = 0;
    _chunkerCounter = 0;
}
예제 #3
0
파일: program.c 프로젝트: polarcat/zztest
int program_make(struct program *prog, struct shader **shader, int num)
{
	int i;
	GLchar log[256] = "nil";
	GLsizei len = 0;
	GLint res = GL_FALSE;

	if (!prog) {
		errno = EFAULT;
		return -1;
	}

	timeinit();

	prog->id = glCreateProgram();
	if (prog->id == 0) {
		glerr("glCreateProgram() failed");
		return -1;
	}

	prog->shader = shader;
	prog->shader_num = num;

	for (i = 0; i < num; i++) {
		if (make_shader(shader[i]) < 0) {
			_err("shader %s failed\n", shader[i]->name);
			goto err;
		}
		glAttachShader(prog->id, shader[i]->id);
	}

	timestart();
	glLinkProgram(prog->id);
	glGetProgramiv(prog->id, GL_LINK_STATUS, &res);
	if (res != GL_TRUE) {
		_err("failed to link program\n");
		goto err;
	}

	timestop("program %d linked\n", prog->id);
	return prog->id;

err:
	if (prog->id > 0) {
		glGetProgramInfoLog(prog->id, sizeof (log), &len, log);
		_msg("len: %d, log: %s\n", len, log);
	}

	program_clean(prog);
	return -1;
}
예제 #4
0
int nsh_telnetstart(void)
{
  struct telnetd_config_s config;
  int ret;

  /* Initialize any USB tracing options that were requested.  If standard
   * console is also defined, then we will defer this step to the standard
   * console.
   */

#if defined(CONFIG_NSH_USBDEV_TRACE) && !defined(CONFIG_NSH_CONSOLE)
  usbtrace_enable(TRACE_BITSET);
#endif

  /* Configure the telnet daemon */

  config.d_port      = HTONS(CONFIG_NSH_TELNETD_PORT);
  config.d_priority  = CONFIG_NSH_TELNETD_DAEMONPRIO;
  config.d_stacksize = CONFIG_NSH_TELNETD_DAEMONSTACKSIZE;
  config.t_priority  = CONFIG_NSH_TELNETD_CLIENTPRIO;
  config.t_stacksize = CONFIG_NSH_TELNETD_CLIENTSTACKSIZE;
  config.t_entry     = nsh_telnetmain;

  /* Start the telnet daemon */

  _info("Starting the Telnet daemon\n");
  ret = telnetd_start(&config);
  if (ret < 0)
    {
      _err("ERROR: Failed to tart the Telnet daemon: %d\n", ret);
    }

  return ret;
}
예제 #5
0
void ps_free(ps_node* node)
{
    struct array *what = NULL;

    switch (node->type) {
        case NODE_BOOL   : 
        case NODE_INT    : 
        case NODE_FLOAT  :
        case NODE_NULL   : break;
        case NODE_STRING : free(node->val.s.val); break;
        case NODE_OBJECT :
            what = &node->val.o.val;
            free(node->val.o.type);
            goto inside_array;
        case NODE_ARRAY  :
            what = &node->val.a;
        inside_array:
            for (int i = 0; i < what->len; i++) {
                ps_free(what->pairs[i].key);
                ps_free(what->pairs[i].val);
            }
            free(what->pairs);
            break;
        default:
            _err("Invalid node type %d in %s", node->type, __func__);
    };

    free(node);
}
예제 #6
0
static ps_node *ps_dispatch(struct ps_parser_state *state, int *pos)
{
    ps_node *result = NULL;

    const char *input = state->chunker(state->userdata, *pos, 1);
    if (!input)
        return NULL;

    int here = 0;
    while (isspace(input[here]))
        here++;

    (*pos) += here;

    switch (input[here]) {
        case NODE_ARRAY:  result = ps_handle_array (state, pos); break;
        case NODE_BOOL:   result = ps_handle_bool  (state, pos); break;
        case NODE_FLOAT:  result = ps_handle_float (state, pos); break;
        case NODE_INT:    result = ps_handle_int   (state, pos); break;
        case NODE_NULL:   result = ps_handle_null  (state, pos); break;
        case NODE_OBJECT: result = ps_handle_object(state, pos); break;
        case NODE_STRING: result = ps_handle_string(state, pos); break;

        case '}':
        case ';': (*pos)++; result = ps_dispatch(state, pos); break;

        default:
            _err("ERROR: Parse failure in %s", __func__);
            return PS_PARSE_FAILURE;
    }

    return result;
}
예제 #7
0
파일: sam_irq.c 프로젝트: a1ien/nuttx
static int sam_busfault(int irq, FAR void *context)
{
  (void)up_irq_save();
  _err("PANIC!!! Bus fault received: %08x\n", getreg32(NVIC_CFAULTS));
  PANIC();
  return 0;
}
예제 #8
0
static int up_setcursor(FAR struct fb_vtable_s *vtable,
                       FAR struct fb_setcursor_s *setttings)
{
  _info("vtable=%p setttings=%p\n", vtable, setttings);
  if (vtable && setttings)
    {
      _info("flags:   %02x\n", settings->flags);
      if ((flags & FB_CUR_SETPOSITION) != 0)
        {
          g_cpos = settings->pos;
          _info("pos:     (h:%d, w:%d)\n", g_cpos.x, g_cpos.y);
        }
#ifdef CONFIG_FB_HWCURSORSIZE
      if ((flags & FB_CUR_SETSIZE) != 0)
        {
          g_csize = settings->size;
          _info("size:    (h:%d, w:%d)\n", g_csize.h, g_csize.w);
        }
#endif
#ifdef CONFIG_FB_HWCURSORIMAGE
      if ((flags & FB_CUR_SETIMAGE) != 0)
        {
          _info("image:   (h:%d, w:%d) @ %p\n",
               settings->img.height, settings->img.width, settings->img.image);
        }
#endif
      return OK;
    }

  _err("ERROR: Returning EINVAL\n");
  return -EINVAL;
}
예제 #9
0
static int up_getcmap(FAR struct fb_vtable_s *vtable, FAR struct fb_cmap_s *cmap)
{
  int len;
  int i;

  _info("vtable=%p cmap=%p len=%d\n", vtable, cmap, cmap->len);
  if (vtable && cmap)
    {
      for (i = cmap->first, len = 0; i < 256 && len < cmap->len; i++, len++)
        {
          cmap->red[i]    = i;
          cmap->green[i]  = i;
          cmap->blue[i]   = i;
#ifdef CONFIG_FB_TRANSPARENCY
          cmap->transp[i] = i;
#endif
        }

      cmap->len = len;
      return OK;
    }

  _err("ERROR: Returning EINVAL\n");
  return -EINVAL;
}
예제 #10
0
파일: ov2640.c 프로젝트: a1ien/nuttx
static int ov2640_putreg(FAR struct i2c_master_s *i2c, uint8_t regaddr,
                         uint8_t regval)
{
  struct i2c_config_s config;
  uint8_t buffer[2];
  int ret;

#ifdef CONFIG_OV2640_REGDEBUG
   _err("%02x <- %02x\n", regaddr, regval);
#endif

  /* Set up for the transfer */

  buffer[0] = regaddr; /* Register address */
  buffer[1] = regval;  /* New register value */

  /* Set up the I2C configuration */

  config.frequency = CONFIG_OV2640_FREQUENCY;
  config.address   = CONFIG_OV2640_I2CADDR;
  config.addrlen   = 7;

  /* And do it */

  ret = i2c_write(i2c, &config, buffer, 2);
  if (ret < 0)
    {
      gerr("ERROR: i2c_write failed: %d\n", ret);
      return ret;
    }

  return OK;
}
예제 #11
0
int ConnectionServer::CreateConnection(int fd,int flag)
{

	/*
	SocketHandle * newhdle = new SocketHandle;
	newhdle->set_flag(flag);
	newhdle->set_fd(fd);
	insert_handle(fd,newhdle);
	*/
	Connection* conn = new Connection(fd);
	conn->SetConnectionManager(this);
	conn->SetFlag(flag);
	pthread_mutex_lock(&_map_mutex);
	std::pair< std::map<int, Connection*>::iterator, bool> ret = 
	m_fd_set.insert(std::map<int, Connection*>::value_type(fd, conn));
	pthread_mutex_unlock(&_map_mutex);
	if(!ret.second)
	{
		_err("ConnectionServer::CreateConnection <btlswkxt> insert map error!!\n");
		return -1;
	}
	
	return 0;

}
예제 #12
0
int sam_pwm_setup(void)
{
  static bool initialized = false;
  struct pwm_lowerhalf_s *pwm;
  int ret;

  /* Have we already initialized? */

  if (!initialized)
    {
      /* Call sam_pwminitialize() to get an instance of the PWM interface */

      pwm = sam_pwminitialize(CONFIG_SAMA5D4EK_CHANNEL);
      if (!pwm)
        {
          _err("ERROR: Failed to get the SAMA5 PWM lower half\n");
          return -ENODEV;
        }

      /* Register the PWM driver at "/dev/pwm0" */

      ret = pwm_register("/dev/pwm0", pwm);
      if (ret < 0)
        {
          aerr("ERROR: pwm_register failed: %d\n", ret);
          return ret;
        }

      /* Now we are initialized */

      initialized = true;
    }

  return OK;
}
예제 #13
0
파일: kinetis_irq.c 프로젝트: a1ien/nuttx
static int kinetis_busfault(int irq, FAR void *context)
{
  (void)up_irq_save();
  _err("PANIC!!! Bus fault recived\n");
  PANIC();
  return 0;
}
예제 #14
0
파일: sam_irq.c 프로젝트: a1ien/nuttx
static int sam_pendsv(int irq, FAR void *context)
{
  (void)up_irq_save();
  _err("PANIC!!! PendSV received\n");
  PANIC();
  return 0;
}
예제 #15
0
파일: sam_irq.c 프로젝트: a1ien/nuttx
static int sam_reserved(int irq, FAR void *context)
{
  (void)up_irq_save();
  _err("PANIC!!! Reserved interrupt\n");
  PANIC();
  return 0;
}
예제 #16
0
파일: stm32_irq.c 프로젝트: dagar/NuttX
static int stm32_usagefault(int irq, FAR void *context, FAR void *arg)
{
  (void)up_irq_save();
  _err("PANIC!!! Usage fault received: %08x\n", getreg32(NVIC_CFAULTS));
  PANIC();
  return 0;
}
예제 #17
0
파일: stm32_irq.c 프로젝트: dagar/NuttX
static int stm32_dbgmonitor(int irq, FAR void *context, FAR void *arg)
{
  (void)up_irq_save();
  _err("PANIC!!! Debug Monitor received\n");
  PANIC();
  return 0;
}
예제 #18
0
/*
 * sl_init(): Initialize a string list
 */
StringList *
sl_init(void)
{
	StringList *sl;

	sl = malloc(sizeof(StringList));
	if (sl == NULL)
		_err(1, "stringlist: %m");

	sl->sl_cur = 0;
	sl->sl_max = _SL_CHUNKSIZE;
	sl->sl_str = malloc(sl->sl_max * sizeof(char *));
	if (sl->sl_str == NULL)
		_err(1, "stringlist: %m");
	return sl;
}
예제 #19
0
static mleak_mem_node_t*
_node_find(
    unsigned long    ptr)
{
    mleak_mem_node_t    *pCur = g_mleak_dev.pNode_head;
    mleak_mem_node_t    *pTarget = 0;

    while( pCur )
    {
        if( pCur->verify_tag != MLEAK_VERIFY_TAG )
        {
            _err("fail, node is dirty !!\n");
            break;
        }

        if( (unsigned long)((void*)(pCur->pPtr)) == ptr )
        {
            pTarget = pCur;
            break;
        }

        pCur = pCur->next;
    }

    return pTarget;
}
/**
 * @details
 * Constructor.
 *
 * @param[in] config XML configuration node.
 */
PPFChanneliser::PPFChanneliser(const ConfigNode& config)
: AbstractModule(config), _buffersInitialised(false)
{
    // Get options from the XML configuration node.
    _nChannels = config.getOption("outputChannelsPerSubband", "value", "512").toUInt();
    _nThreads  = config.getOption("processingThreads", "value", "2").toUInt();
    unsigned nTaps = config.getOption("filter", "nTaps", "8").toUInt();
    QString window = config.getOption("filter", "filterWindow", "kaiser").toLower();

    // Set the number of processing threads.
    omp_set_num_threads(_nThreads);
    _iOldestSamples.resize(_nThreads, 0);

    // Enforce even number of channels.
    if (_nChannels != 1 && _nChannels%2 == 1)
       throw _err("Number of channels needs to be even.");

    // Generate the FIR coefficients;
    _generateFIRCoefficients(window, nTaps);

    // Allocate buffers used for holding the output of the FIR stage.
    _filteredData.resize(_nThreads);
    for (unsigned i = 0; i < _nThreads; ++i)
        _filteredData[i].resize(_nChannels);

    // Create the FFTW plan.
    _createFFTWPlan(_nChannels, _fftPlan);
}
예제 #21
0
static int xmc4_usagefault(int irq, FAR void *context, FAR void *arg)
{
  (void)up_irq_save();
  _err("PANIC!!! Usage fault received\n");
  PANIC();
  return 0;
}
예제 #22
0
static int lpc43_busfault(int irq, FAR void *context, FAR void *arg)
{
  (void)up_irq_save();
  _err("PANIC!!! Bus fault recived\n");
  PANIC();
  return 0;
}
예제 #23
0
static int open_outfile(int fnum, int cpu, int remove_file)
{
    char buf[PATH_MAX];
    time_t t;
    if (!outfile_name) {
        _err("-S is set without -o. Please file a bug report.\n");
        return -1;
    }

    time(&t);
    if (fnum_max) {
        if (remove_file) {
            /* remove oldest file */
            if (make_outfile_name(buf, PATH_MAX, fnum - fnum_max,
                                  cpu, read_backlog(cpu, fnum - fnum_max),
                                  bulkmode) < 0)
                return -1;
            remove(buf); /* don't care */
        }
        write_backlog(cpu, fnum, t);
    }

    if (make_outfile_name(buf, PATH_MAX, fnum, cpu, t, bulkmode) < 0)
        return -1;
    out_fd[cpu] = open (buf, O_CREAT|O_TRUNC|O_WRONLY, 0666);
    if (out_fd[cpu] < 0) {
        perr("Couldn't open output file %s", buf);
        return -1;
    }
    if (set_clexec(out_fd[cpu]) < 0)
        return -1;
    return 0;
}
예제 #24
0
파일: sam_irq.c 프로젝트: a1ien/nuttx
static int sam_nmi(int irq, FAR void *context)
{
  (void)up_irq_save();
  _err("PANIC!!! NMI received\n");
  PANIC();
  return 0;
}
예제 #25
0
int ssynth_init (void) {
 struct roar_stream_server * ss;
 struct roar_stream        *  s;
 int sid;

 if ( !ssynth_conf.enable )
  return 0;

 memset(&g_ssynth, 0, sizeof(g_ssynth));
 g_ssynth.stream = -1;

 if ( (sid = streams_new()) == -1 )
  return -1;

 if ( streams_set_client(sid, g_self_client) == -1 ) {
  _err();
 }

 if ( streams_set_dir(sid, ROAR_DIR_BRIDGE, 1) == -1 ) {
  _err();
 }

 if ( streams_set_flag(sid, ROAR_FLAG_PRIMARY) == -1 ) {
  _err();
 }

 if ( streams_set_name(sid, "Simple Synthesizer") == -1 ) {
  _err();
 }

 if ( streams_get(sid, &ss) == -1 ) {
  _err();
 }

 s = ROAR_STREAM(ss);

 memcpy(&(s->info), g_sa, sizeof(struct roar_audio_info));

 s->info.channels = 1;
 s->info.codec    = ROAR_CODEC_DEFAULT;

 g_ssynth.stream  = sid;

 return 0;
}
예제 #26
0
int ConnectionServer::Open(size_t thread_num, int port)
{
	struct sockaddr_in addr; 
	struct hostent *host;     
	struct ifreq req; 
	int sock; 
	char *dn_or_ip; 

	sock = socket(AF_INET, SOCK_DGRAM, 0); 
	strncpy(req.ifr_name, "eth0", IFNAMSIZ); 

	if ( ioctl(sock, SIOCGIFADDR, &req) < 0 ) { 
		_err("ConnectionServer::Open ioctl error: %s Cann't get current IP\n", strerror (errno)); 
		sprintf(current_ip,"Get currentip error %d",errno); 
	} 
	else 
	{ 
		dn_or_ip = (char *)inet_ntoa(*(struct in_addr *) &((struct sockaddr_in *) &req.ifr_addr)->sin_addr); 
		strcpy(current_ip,dn_or_ip); 
	} 
	_info("ConnectionServer::Open Current IP:%s\n", current_ip); 
	shutdown(sock, 2); 
	::close(sock);

	if ((_epoll_fd = epoll_create(MAX_FD_NUM)) == -1)
	{
		_err("error: epoll create fail!!\n");
		return -1;
	}
	if (create_pipe())
	{
		_err("error: create pipe fail!! \n");
		return -1;
	}
	if (create_listen(_socket_server_listen, port))
	{
		_err("error: create listen fail !! %d\n",port);
		return -1;
	}

	add_input_fd(_pipe_read);
	add_input_fd(_socket_server_listen);

	return STaskBase<Connection*>::Open(thread_num);
}
예제 #27
0
static ps_node *ps_handle_string(struct ps_parser_state *state, int *pos)
{
    ps_node *result = NULL;

    const char *input = state->chunker(state->userdata, *pos, 10);
    if (!input)
        return NULL;

    char *next;
    int len = strtol(&input[2], &next, 10);
    if (next == input) {
        _err("ERROR: Parse failure in %s", __func__);
        return PS_PARSE_FAILURE;
    }

    /// @todo make an expect() call
    if (strncmp(next, ":\"", 2)) {
        char got[3] = { 0 };
        strncpy(got, next, 2);
        _err("ERROR: Parse failure in %s : expecting \":\"\", got \"%s\"",
                __func__, got);
        return PS_PARSE_FAILURE;
    }

    (*pos) += next - input + 2; // 1 for colon, 1 for opening quote
    input = state->chunker(state->userdata, *pos, len);
    if (!input)
        return NULL;

    char *val = malloc(len + 1);
    /// @todo what about possibly escaped characters ?
    strncpy(val, next + 2, len);
    val[len] = 0;

    result = malloc(sizeof *result);
    *result = (ps_node){
        .type = NODE_STRING,
        .val = { .s = { .len = len, .val = val } }
    };

    (*pos) += len + 1;  // 1 for closing quote

    return result;
}
예제 #28
0
static ps_node *ps_handle_object(struct ps_parser_state *state, int *pos)
{
    ps_node *result = NULL;

    const char *input = state->chunker(state->userdata, *pos, 10);
    if (!input) return PS_PARSE_FAILURE;

    char *next;
    int typelen = strtol(&input[2], &next, 10);
    if (next == input) {
        _err("ERROR: Parse failure in %s", __func__);
        return PS_PARSE_FAILURE;
    }

    (*pos) += next - input;;
    // +2 for quotes
    input = state->chunker(state->userdata, *pos, typelen + 2);
    if (!input) return PS_PARSE_FAILURE;

    char type[typelen + 1];
    memcpy(type, &input[2], typelen);
    type[typelen] = 0;
    (*pos) += typelen + 4;
    input = state->chunker(state->userdata, *pos, 10);
    if (!input) return PS_PARSE_FAILURE;

    int len = strtol(input, &next, 10);
    if (next == input) {
        _err("ERROR: Parse failure in %s", __func__);
        return PS_PARSE_FAILURE;
    }

    (*pos) += next - input + 2; // 2 for ":{"

    result = malloc(sizeof *result);
    if (_ps_object_or_array(state, pos, len, &result->val.o.val) == PS_PARSE_FAILURE)
        return PS_PARSE_FAILURE;
    result->type = NODE_OBJECT;
    result->val.o.type = strdup(type);
    result->val.o.val.is_array = false;

    return result;
}
예제 #29
0
int Connection::ReadTimeout(void *buf, size_t buf_len, timeval *timeout)
{
	//buf_len =1024;
	//char * buff= new char[buf_len];	
	//char * old_buf =buff;
	int left = buf_len;
	int n;
	fd_set rset;
	if (_fd == INVALID_FD){
		_err("ReadTimeout fd is INVALID\n");
		goto ERROR;
	}
	while (left > 0)
	{
		//fprintf(stderr, "############3333 000000 readn_timout is left:%d,fd:%d ",left,_fd);	
		FD_ZERO(&rset);
		FD_SET(_fd, &rset);
		if (select(_fd + 1, &rset, NULL, NULL, timeout) <= 0){
			_err("Connection::ReadTimeout select error\n");
			goto ERROR;
		}
		if ((n = read(_fd, buf, left)) == 0){
			//fprintf(stderr, "############3333 readn_timout is left:%d,fd:%d ",left,_fd);	
			//return buf_len - left;
			buf_len = buf_len - left;
			goto OUT;
		}
		buf = (char *)buf + n;
		left -= n;
	}
OUT:
	/*fprintf(stderr,"========================\n");
	for (int i =0 ;i<buf_len;i++)
		fprintf(stderr," %x ",old_buf[i]);
	fprintf(stderr,"\n========================.done\n");
	*/
	//fprintf(stderr,"\n======================== buf_len =%d\n",buf_len);
	return buf_len;
ERROR:
	return -1;

}
예제 #30
0
파일: sam_bringup.c 프로젝트: dagar/NuttX
static void sam_i2c_register(int bus)
{
  FAR struct i2c_master_s *i2c;
  int ret;

  i2c = sam_i2cbus_initialize(bus);
  if (i2c == NULL)
    {
      _err("ERROR: Failed to get I2C%d interface\n", bus);
    }
  else
    {
      ret = i2c_register(i2c, bus);
      if (ret < 0)
        {
          _err("ERROR: Failed to register I2C%d driver: %d\n", bus, ret);
          sam_i2cbus_uninitialize(i2c);
        }
    }
}