src/stlink-usb.c
/* See section C1.6 of the ARMv7-M Architecture Reference Manual */
See section C1.6 of the ARMv7-M Architecture Reference Manual
See section C1 . 6 of the ARMv7 - M Architecture Reference Manual
void _stlink_usb_read_unsupported_reg(stlink_t *sl, int r_idx, reg *regp) {
    uint32_t r;
    sl->q_buf[0] = (unsigned char) r_idx;
    for (int i = 1; i < 4; i++) {
        sl->q_buf[i] = 0;
    }
    _stlink_usb_write_mem32(sl, DCRSR, 4);
    _stlink_usb_read_mem32(sl, DCRDR, 4);
    r = read_uint32(sl->q_buf, 0);
    DLOG("r_idx (%2d) = 0x%08x\n", r_idx, r);
    switch (r_idx) {
    case 0x14:
        regp->primask = (uint8_t) (r & 0xFF);
        regp->basepri = (uint8_t) ((r>>8) & 0xFF);
        regp->faultmask = (uint8_t) ((r>>16) & 0xFF);
        regp->control = (uint8_t) ((r>>24) & 0xFF);
        break;
    case 0x21:
        regp->fpscr = r;
        break;
    default:
        regp->s[r_idx - 0x40] = r;
        break;
    }
}
void _stlink_usb_read_unsupported_reg ( stlink_t * sl , int r_idx , reg * regp ) { uint32_t r ; sl -> q_buf [ 0 ] = ( unsigned char ) r_idx ; for ( int i = 1 ; i < 4 ; i ++ ) { sl -> q_buf [ i ] = 0 ; } _stlink_usb_write_mem32 ( sl , DCRSR , 4 ) ; _stlink_usb_read_mem32 ( sl , DCRDR , 4 ) ; r = read_uint32 ( sl -> q_buf , 0 ) ; DLOG ( " \n " , r_idx , r ) ; switch ( r_idx ) { case 0x14 : regp -> primask = ( uint8_t ) ( r & 0xFF ) ; regp -> basepri = ( uint8_t ) ( ( r >> 8 ) & 0xFF ) ; regp -> faultmask = ( uint8_t ) ( ( r >> 16 ) & 0xFF ) ; regp -> control = ( uint8_t ) ( ( r >> 24 ) & 0xFF ) ; break ; case 0x21 : regp -> fpscr = r ; break ; default : regp -> s [ r_idx - 0x40 ] = r ; break ; } }
See section C1.6 of the ARMv7-M Architecture Reference Manual
See section C1 . 6 of the ARMv7 - M Architecture Reference Manual