Closed-loop brain-machine interfaces (BMI) provide a mutual learning paradigm where a machine learns how to recognize a user's brain states while the user also adapts to the decoder feedback of the machine to improve the overall performance. In this talk, we present some BMI that concerns the detection of a user's intention to move his/her own upper or lower limbs as well as error-related signals which occurs when a user detects a mismatch between the observation and expectation. Finally, we show a rehabilitation application of a chronic paraplegic user who has shown improvements in motor and sensor functions after trained with BMI.