function_name
stringlengths
1
80
function
stringlengths
14
10.6k
comment
stringlengths
12
8.02k
normalized_comment
stringlengths
6
6.55k
u8g_is_intersection_decision_tree
uint8_t u8g_is_intersection_decision_tree(uint8_t a0, uint8_t a1, uint8_t v0, uint8_t v1) { if ( v0 < a1 ) // v0 <= a1 { if ( v1 > a0 ) // v1 >= a0 { return 1; } else { if ( v0 > v1 ) // v0 > v1 { return 1; } else { return 0; } } } else { if ( v1 > a0 ) // v1 >= a0 { if ( v0 > v1 ) // v0 > v1 { return 1; } else { return 0; } } else { return 0; } } }
/* version with asymetric boundaries. a1 and v1 are excluded v0 == v1 is not support end return 1 */
version with asymetric boundaries. a1 and v1 are excluded v0 == v1 is not support end return 1
onDelta
static void onDelta(struct jsonrpc_request *r) { const char *s = NULL; int len = 0; mjson_find(r->params, r->params_len, "$.state", &s, &len); if (s) mDashShadowUpdate("{%Q:{%Q:%.*s}}", "state", "reported", len, s); }
/* clearing the delta - whatever it is, without performing any actual action.*/
clearing the delta - whatever it is, without performing any actual action.
ucg_ext_none
ucg_int_t ucg_ext_none(ucg_t *ucg, ucg_int_t msg, void *data) { return 1; /* all ok */ }
/* will be used as default cb if no extentions callback is provided */
will be used as default cb if no extentions callback is provided
ucg_font_calc_vref_font
ucg_int_t ucg_font_calc_vref_font(ucg_t *ucg) { return 0; }
/* callback procedures to correct the y position */
callback procedures to correct the y position
sn_grs_destroy
extern int8_t sn_grs_destroy(struct grs_s *handle) { if( handle == NULL ){ return 0; } ns_list_foreach_safe(sn_nsdl_dynamic_resource_parameters_s, tmp, &handle->resource_root_list) { ns_list_remove(&handle->resource_root_list, tmp); --handle->resource_root_count; sn_grs_resource_info_free(handle, tmp); } handle->sn_grs_free(handle); return 0; }
/** * \fn int8_t sn_grs_destroy(void) * \brief This function may be used to flush GRS related stuff when a program exits. * @return always 0. */
\fn int8_t sn_grs_destroy(void) \brief This function may be used to flush GRS related stuff when a program exits. @return always 0.
twi_init
void twi_init(void) { // initialize state twi_state = TWI_READY; twi_sendStop = true; // default value twi_inRepStart = false; // activate internal pullups for twi. // digitalWrite(SDA, 1); PORTD |= _BV(0); // digitalWrite(SCL, 1); PORTD |= _BV(1); // initialize twi prescaler and bit rate cbi(TWSR, TWPS0); cbi(TWSR, TWPS1); TWBR = ((F_CPU / TWI_FREQ) - 16) / 2; /* twi bit rate formula from atmega128 manual pg 204 SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR)) note: TWBR should be 10 or higher for master mode It is 72 for a 16mhz Wiring board with 100kHz TWI */ // enable twi module, acks, and twi interrupt TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA); }
/* * Function twi_init * Desc readys twi pins and sets twi bitrate * Input none * Output none */
Function twi_init Desc readys twi pins and sets twi bitrate Input none Output none
twi_disable
void twi_disable(void) { // disable twi module, acks, and twi interrupt TWCR &= ~(_BV(TWEN) | _BV(TWIE) | _BV(TWEA)); // deactivate internal pullups for twi. // digitalWrite(SDA, 0); PORTD &= ~_BV(0); // digitalWrite(SCL, 0); PORTD &= ~_BV(1); }
/* * Function twi_disable * Desc disables twi pins * Input none * Output none */
Function twi_disable Desc disables twi pins Input none Output none
twi_setAddress
void twi_setAddress(uint8_t address) { // set twi slave address (skip over TWGCE bit) TWAR = address << 1; }
/* * Function twi_slaveInit * Desc sets slave address and enables interrupt * Input none * Output none */
Function twi_slaveInit Desc sets slave address and enables interrupt Input none Output none
twi_setFrequency
void twi_setFrequency(uint32_t frequency) { TWBR = ((F_CPU / frequency) - 16) / 2; /* twi bit rate formula from atmega128 manual pg 204 SCL Frequency = CPU Clock Frequency / (16 + (2 * TWBR)) note: TWBR should be 10 or higher for master mode It is 72 for a 16mhz Wiring board with 100kHz TWI */ }
/* * Function twi_setClock * Desc sets twi bit rate * Input Clock Frequency * Output none */
Function twi_setClock Desc sets twi bit rate Input Clock Frequency Output none
twi_attachSlaveRxEvent
void twi_attachSlaveRxEvent(void (*function)(uint8_t*, int)) { twi_onSlaveReceive = function; }
/* * Function twi_attachSlaveRxEvent * Desc sets function called before a slave read operation * Input function: callback function to use * Output none */
Function twi_attachSlaveRxEvent Desc sets function called before a slave read operation Input function: callback function to use Output none
twi_attachSlaveTxEvent
void twi_attachSlaveTxEvent(void (*function)(void)) { twi_onSlaveTransmit = function; }
/* * Function twi_attachSlaveTxEvent * Desc sets function called before a slave write operation * Input function: callback function to use * Output none */
Function twi_attachSlaveTxEvent Desc sets function called before a slave write operation Input function: callback function to use Output none
twi_reply
void twi_reply(uint8_t ack) { // transmit master read ready signal, with or without ack if (ack) { TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT) | _BV(TWEA); } else { TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWINT); } }
/* * Function twi_reply * Desc sends byte or readys receive line * Input ack: byte indicating to ack or to nack * Output none */
Function twi_reply Desc sends byte or readys receive line Input ack: byte indicating to ack or to nack Output none
twi_stop
void twi_stop(void) { // send stop condition TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT) | _BV(TWSTO); // wait for stop condition to be exectued on bus // TWINT is not set after a stop condition! while (TWCR & _BV(TWSTO)) { continue; } // update twi state twi_state = TWI_READY; }
/* * Function twi_stop * Desc relinquishes bus master status * Input none * Output none */
Function twi_stop Desc relinquishes bus master status Input none Output none
twi_releaseBus
void twi_releaseBus(void) { // release bus TWCR = _BV(TWEN) | _BV(TWIE) | _BV(TWEA) | _BV(TWINT); // update twi state twi_state = TWI_READY; }
/* * Function twi_releaseBus * Desc releases bus control * Input none * Output none */
Function twi_releaseBus Desc releases bus control Input none Output none
CalcCRC
uint8_t CalcCRC(BowlerPacket *Packet) { uint32_t v = 0; int i; for (i = 0; i < 10; i++) v += (uint32_t) Packet->stream[i]; return (uint8_t)(v & 0x000000ff); }
/* * Calculate waht the CRC should be for a given data section */
Calculate waht the CRC should be for a given data section
CheckCRC
uint8_t CheckCRC(BowlerPacket *Packet) { uint8_t v = CalcCRC(Packet); if (Packet->use.head.CRC == v) return true; return false; }
/* * Returns true if the data crc in the packet matches the one calculated fromthe packet */
Returns true if the data crc in the packet matches the one calculated fromthe packet
SetCRC
void SetCRC(BowlerPacket * Packet) { uint8_t v = CalcCRC(Packet); Packet->use.head.CRC = v; }
/* * Calculates and sets the CRC in the packet */
Calculates and sets the CRC in the packet
CalcDataCRC
uint8_t CalcDataCRC(BowlerPacket *Packet) { uint32_t v = 0; int i; for (i = 0; i < Packet->use.head.DataLegnth; i++) v +=(uint32_t) Packet->stream[i+_BowlerHeaderSize]; return (uint8_t)(v & 0x000000ff); }
/* * Calculate waht the CRC should be for a given data section */
Calculate waht the CRC should be for a given data section
CheckDataCRC
uint8_t CheckDataCRC(BowlerPacket *Packet) { uint8_t v = CalcDataCRC(Packet); if (GetDataCRC( Packet) == v) return true; return false; }
/* * Returns true if the data crc in the packet matches the one calculated fromthe packet */
Returns true if the data crc in the packet matches the one calculated fromthe packet
SetDataCRC
void SetDataCRC(BowlerPacket * Packet) { //println_W("data CRC"); uint8_t v = CalcDataCRC(Packet); Packet->stream[Packet->use.head.DataLegnth+_BowlerHeaderSize] = v; }
/* * Calculates and sets the CRC in the packet */
Calculates and sets the CRC in the packet
GetDataCRC
uint8_t GetDataCRC(BowlerPacket * Packet) { return Packet->stream[Packet->use.head.DataLegnth+_BowlerHeaderSize] ; }
/* * Calculates and sets the CRC in the packet */
Calculates and sets the CRC in the packet
bcsSafeAsyncEventCallback
boolean bcsSafeAsyncEventCallback(BowlerPacket *Packet, boolean(*pidAsyncCallbackPtr)(BowlerPacket *Packet)) { //println_I("Safe Async "); return false; }
/*char safeNSName[] = "bcs.safe.*;0.3;;";*/
char safeNSName[] = "bcs.safe.*;0.3;;";
bcsIoSetmodeAsyncEventCallback
boolean bcsIoSetmodeAsyncEventCallback(BowlerPacket *Packet, boolean(*pidAsyncCallbackPtr)(BowlerPacket *Packet)) { //no async //println_I("Setmode async "); return false; }
/*char setModeNSName[] = "bcs.io.setmode.*;0.3;;";*/
char setModeNSName[] = "bcs.io.setmode.*;0.3;;";
ProcessPIDPacket
boolean ProcessPIDPacket(BowlerPacket * Packet){ switch(Packet->use.head.Method){ case BOWLER_GET: return processPIDGet(Packet); case BOWLER_POST: return processPIDPost(Packet); case BOWLER_CRIT: return processPIDCrit(Packet); default: return false; } }
/** * Handle a PID packet. * @return True if the packet was processed, False if it was not PID packet */
Handle a PID packet. @return True if the packet was processed, False if it was not PID packet
InitilizeBcsIoSetmode
void InitilizeBcsIoSetmode(boolean (*setChanelModeHWPtrLocal)(uint8_t ,uint8_t)){ if(setChanelModeHWPtrLocal == NULL){ setPrintLevelErrorPrint(); //println_E("Failed IO.SETMODE sanity check: initialization"); while(1); } setChanelModeHWPtr = setChanelModeHWPtrLocal; }
/* * Initialize SetMode hardware interface functions */
Initialize SetMode hardware interface functions
SetChannelMode
boolean SetChannelMode(uint8_t pin,uint8_t mode){ if(setChanelModeHWPtr == NULL){ //println_E("Set mode pointer not set!") return false; } boolean ok = setChanelModeHWPtr(pin,mode); //print_I(" Hardware ok"); if(IsAsync(pin)){ //print_I(" Restarting async"); startAdvancedAsyncDefault(pin); } return ok; }
/* * Set Channel Mode * Sets the given channel to the given mode * Returns true if successful */
Set Channel Mode Sets the given channel to the given mode Returns true if successful
AbstractSetChannelMode
boolean AbstractSetChannelMode(BowlerPacket * Packet){ //printBowlerPacketDEBUG(Packet,WARN_PRINT); uint8_t pin =Packet->use.data[0]; uint8_t mode=Packet->use.data[1]; //printBowlerPacketDEBUG(Packet,WARN_PRINT); println_I("Abstract_bcs_io_setmode Setting Mode: ");printMode(mode,GetChannelMode(pin),INFO_PRINT);print_I(" on: ");p_int_I(pin); if(SetChannelMode(pin,mode)){ GetAllChannelModeFromPacket(Packet); //printBowlerPacketDEBUG(Packet,WARN_PRINT); return true; }else{ GetAllChannelModeFromPacket(Packet); return false; } }
/* * Set Channel Mode * Sets the given channel to the given mode * Returns true if successful */
Set Channel Mode Sets the given channel to the given mode Returns true if successful
getStream
uint16_t getStream(uint8_t *packet,uint16_t size,BYTE_FIFO_STORAGE * fifo){ return FifoGetByteStream(fifo,packet,size); }
/** * get a stream of this length from the connection */
get a stream of this length from the connection
pidAsyncEventCallbackLocal
boolean pidAsyncEventCallbackLocal(BowlerPacket *Packet, boolean(*pidAsyncCallbackPtr)(BowlerPacket *Packet)) { // println_I("\n"); // printPIDvals(0); //println_I("PID COms"); RunPIDComs(Packet, pidAsyncCallbackPtr); return false; }
/*const char pidNSName[] = "bcs.pid.*;1.0;;";*/
const char pidNSName[] = "bcs.pid.*;1.0;;";
printFiFoState
void printFiFoState(BYTE_FIFO_STORAGE * fifo,Print_Level l){ int i; print_nnl("\nFifo state: \tBytes:",l); p_int(calcByteCount(fifo),l); print_nnl("\tData [ ",l); for(i=0;i<calcByteCount(fifo);i++){ p_int(FifoReadByteAtIndex(fifo,i),l);print_nnl(" ",l); } print_nnl(" ]\n",l); }
/*const char * error = "@##ERROR fifo is overflown! Size, buffer: ";*/
const char * error = "@##ERROR fifo is overflown! Size, buffer: ";
clearByteFifo
void clearByteFifo(BYTE_FIFO_STORAGE * fifo){ int i; for (i=0;i < fifo->bufferSize;i++){ fifo->buffer[i]=0; } //EndCritical(); }
/*b_println(fifoinit);p_int(size);*/
b_println(fifoinit);p_int(size);
printMode
void printMode(uint8_t pin,uint8_t newMode, Print_Level l){ uint8_t mode =GetChannelMode(pin); printModeLocal( mode, l); print_nnl(" ,",l); printModeLocal( newMode, l); }
/*char * unknown = "UNKNOWN";*/
char * unknown = "UNKNOWN";
Bowler_Init
void Bowler_Init(void) { addNamespaceToList( getBcsCoreNamespace()); addNamespaceToList( getBcsRpcNamespace()); }
/*finish processing the Packet*/
finish processing the Packet
Bowler_Server_Static
uint8_t Bowler_Server_Static(BowlerPacket * Packet, BYTE_FIFO_STORAGE * fifo) { boolean back = GetBowlerPacket(Packet, fifo); if (back) { return process(Packet); ; }//Have a packet return false; }
/** * Run an instance of the server. This uses user defined memory */
Run an instance of the server. This uses user defined memory