Sampling resistor is grounded at one end and the other end is connected to the positive end of the comparator.
The negative end of the comparator is connected to 300mA*2.5Ω=7.5V. When the current is greater than 300mA, the comparator outputs a high level, otherwise, it outputs a low level.
The comparator output can be connected to the microcontroller.