Beispiel #1
0
void putValue(void* aAdr, uint8_t aPType, int32_t* aValue)
{
    union {
        void*     adr; 
        uint8_t*  u8Adr;
        uint16_t* u16Adr;
        //        uint32_t* u32Adr;
    } a;

    a.adr = aAdr;
    if (ISEEADR(aPType))
    {
        if (IS8BIT(aPType))
            eeprom_update_byte(aAdr, ISSIGNED(aPType) ? (int8_t) *aValue : (uint8_t) *aValue);
        else if(IS16BIT(aPType))
            eeprom_update_word(aAdr, ISSIGNED(aPType) ? (int16_t) *aValue : (uint16_t) *aValue);
#ifdef WITH_EE32VALUES
        else if(IS32BIT(aPType))
            eeprom_update_dword(aAdr, ISSIGNED(aPType) ? *aValue : (uint32_t) *aValue);
#endif
    } else if (ISRAMADR(aPType))
    {
        if (IS8BIT(aPType))
            *a.u8Adr = ISSIGNED(aPType) ? (int8_t) *aValue : (uint8_t) *aValue;
        else if(IS16BIT(aPType))
            *a.u16Adr = ISSIGNED(aPType) ? (int16_t) *aValue : (uint32_t) *aValue;
#ifdef WITH_EE32VALUES
        else if(IS32BIT(aPType))
            *a.u32Adr = ISSIGNED(aPType) ?  *aValue : (uint32_t) *aValue;
#endif
    }
    feedback(1, BLINK_MEDIUM, WITH_LED1);
} // getValue
Beispiel #2
0
int iofunc_lseek(resmgr_context_t *ctp, io_lseek_t *msg, iofunc_ocb_t *ocb, iofunc_attr_t *attr) {
	off64_t		offset;

	offset = msg->i.offset;

	switch(msg->i.whence) {
	case SEEK_SET:
		break;

	case SEEK_CUR:
		offset += ocb->offset;
		break;

	case SEEK_END:
		offset += ocb->attr->nbytes;
		break;

	default:
		return EINVAL;
	}

	if(offset < 0) {
		return EINVAL;
	}

	if (IS32BIT(attr, ocb->ioflag) && offset > LONG_MAX)
		return(EOVERFLOW);

	ocb->offset = offset;

	if(msg->i.combine_len & _IO_COMBINE_FLAG) {
		return EOK;
	}

	msg->o = offset;
	return _RESMGR_PTR(ctp, &msg->o, sizeof msg->o);
}