Production of the excited charm mesons D1 and D2* at HERA